Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Valid Date/Date Format


You guys were probably doing this one in third grade...

I have a textbox on a form in which a user enters a date. I want the user to always enter the date in the following format: mm/dd/yy

When they click OK, how can I check to make sure it's a valid date and it's in the format I want, no other format?

Thanks!!




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Check For Valid Date Format
I'm using VBScript in an ASP environment and I have a form field that a user inputs a date they want to search on. I need the date in the format (MM/DD/YYYY) which is what the regional settings is set at. You can not do a mask on the field (not allowed by html). What I have done so far is

1) Check the date using (isDate) function

2) Switch the value using (Format) function

But the problem is when a user inputs "Jan 11" as a value it passes the (isDate) function and the (Format) function coverts it to (01/11/2000) and I can't assume that the user is looking for that date in the year 2000.

Does anyone know of a way to check date format quickly to see if it's valid.

I can write a function that checks the format, but I want the code in the asp page to be minimal, so I'm trying to find a short way of doing it.

Thanks

How Do I Enter A Date In A Valid Format
Hi there folks,
a simple problem which I feel embarassed to ask, my code is as follows:

    If IsDate(txtPropDOB.Text) = True Then
        txtPropDOB.Text = .DOB
        Else: .DOB = 0
    End If

The user enters a date in a textbox in the format - dd/mm/yyyy, but VB does not accept this as a valid date! Can anyone supply any suggestions.

DATE Problems - Change Date Format To European, Get Current Date, Subtract 2 Dates?
Need someone to point me in the right direction/start me off with this please as I am quite clueless on it at present...

I need something that can successfully subtract two dates...


eg. calculate the difference between the current date
02/04/04 (2nd April 04) and 29/03/04 (28th March 04)
...
which will then output a result of 5 days


So what I need to know is...

1.
I need to know how to get the current date from the system clock

2.
I must somehow get my date function converted into European date format (as at present it is in USA format ie. 2nd April 04 is 04/02/04 like April 2nd 04 which is not good!)

3.
and then I must actually SUBTRACT the 2 dates (the current date and a date that is given) from each other to give an integer which I can then use (ie. a value like 5 or 15).


But I have little idea how to go about this


Can anyone please start me off?

DATE Problems - Change Date Format To European, Get Current Date, Subtract 2 Dates?
Need someone to point me in the right direction/start me off with this please as I am quite clueless on it at present...

I need something that can successfully subtract two dates...


eg. calculate the difference between the current date
     02/04/04 (2nd April 04) and 29/03/04 (28th March 04)
     ...
     which will then output a result of 5 days


So what I need to know is...

1.
I need to know how to get the current date from the system clock

2.
I must somehow get my date function converted into European date format (as at present it is in USA format ie. 2nd April 04 is 04/02/04 like April 2nd 04 which is not good!)

3.
and then I must actually SUBTRACT the 2 dates (the current date and a date that is given) from each other to give an integer which I can then use (ie. a value like 5 or 15).


But I have little idea how to go about this


Can anyone please start me off?

DATE Problem - Formatting US Date MM/DD/YY To European Date Format DD/MM/YY
I have a problem whereby the user must enter a date into a field...

The system changes the date format to US standard which is MM/DD/YY
but I need to change the format to DD/MM/YY (European standard)


I have done this using the Format function, but I still have a slight problem
Format(mydate,"dd/mm/yy")

doesnt account for all dates...

for example...
if I enter 31/03/04 this is fine, it will accept it as that

However, if I enter 02/04/04 (todays date - 2nd April 04), it will change it to 04/02/04



Any ideas how I can counter this from happening?

DATE Problem - Formatting US Date MM/DD/YY To European Date Format DD/MM/YY
I have a problem whereby the user must enter a date into a field...

The system changes the date format to US standard which is MM/DD/YY
but I need to change the format to DD/MM/YY (European standard)


I have done this using the Format function, but I still have a slight problem
Format(mydate,"dd/mm/yy")

doesnt account for all dates...

for example...
if I enter 31/03/04 this is fine, it will accept it as that

However, if I enter 02/04/04 (todays date - 2nd April 04), it will change it to 04/02/04



Any ideas how I can counter this from happening?

Change Short Date Format To Long Date Format (windows Api?)
i want that when i load my program, it will change the date settings in my computer (short date to long date). How can i do that?

Setting Long - Short Date Format In Date Time Settings
How can i set the Date Time Setting Format in Control Panel

i m usiing window Xp


also i want the date format in dd/MM/yyyy

Date Conversion As Oracle Database Date Default Format
Select sysdate from dual ; //oracle database
The result is : 28-AUG-04

How to convert “date” in vb to the above format?

Using below statement :
FormatDateTime(Date, vbLongDate) // Saturday, August 28, 2004

Then, combine with string functions (such as instr, left, mid, etc) can be achieved the desired result.

Any shortcut than above mentioned?

Thanks.
vb999

Date Format, Count No. Of Days & Highlight Date In Calendar
<html><div style='background-color:'><DIV>
<P>Hi all,</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Happen to visit this website accidentally and found that it’s very useful to VB beginner like me. <SPAN style="mso-spacerun: yes"> </SPAN>I have the following problems and would appreciate your kind assistance to enlighten me.<SPAN style="mso-spacerun: yes">  </SPAN>Attached is my file for your checking.<SPAN style="mso-spacerun: yes">  </SPAN></P></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"> <?XML:NAMESPACE PREFIX = O /><O:P></O:P></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; tab-stops: list .5in; mso-list: l0 level1 lfo3">1)<SPAN style="FONT: 7pt 'Times New Roman'">      </SPAN>Sometimes, the number of days is incorrect with a big figure (e.g from 1 to 30 Apr) or even a negative figure after I change the system’s date format from “mm/dd/yyyy” to “dd/mm/yyyy”.<SPAN style="mso-spacerun: yes">  </SPAN></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"> <O:P></O:P></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; tab-stops: list .5in; mso-list: l0 level1 lfo3">2)<SPAN style="FONT: 7pt 'Times New Roman'">      </SPAN>In calculating the number of days, I need to exclude Sunday.<SPAN style="mso-spacerun: yes">  </SPAN>By using the “WeekDay (Calendar1) = 7 “ method, I still didn’t get the correct result.<SPAN style="mso-spacerun: yes">  </SPAN></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"> </P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><O:P>      3)  How to highlight a certain date in calendar with different colour to indicate it's a public holiday ? </O:P></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><O:P></O:P> </P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Many thanks in advance.<SPAN style="mso-spacerun: yes">  </SPAN></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"> <O:P></O:P></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Best regards,</P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">YC </P>
<DIV></DIV>
<DIV></DIV>
<P><BR><BR></P>
<DIV></DIV>
<DIV></DIV></div><br clear=all><hr>Add photos to your e-mail with <a href="http://g.msn.com/8HMVEN/2746">MSN 8.</a> Get 2 months FREE*.</html>

Date &amp; Time Values In Date And String Format Differ
The program (debug) output below lists the last modification time of two files. File 1 is stored on a NTFS medium, file 2 sits on a FAT medium.

In order to be able to compare these dates, I need to round the odd seconds of the NTFS file up (FAT files have only even second values).

The lines after the file headers show the date & time value before and after the rounding, in date, double precision and string format.

file 1 (NTFS)
= 2005-07-12 08:57:09 = 38545,3730208333 = 2005-07-12 08:57:09
after rounding up
= 2005-07-12 08:57:10 = 38545,3730324074 = 2005-07-12 08:57:10

file 2 (FAT)
= 2005-07-12 08:57:10 = 38545,3730324074 = 2005-07-12 08:57:10

The strange thing is that when comparing these values, they appear to be different (!) both in date and double data format, not in string format.

2005-07-12 08:57:10 > 2005-07-12 08:57:10 (date format)
38545,3730324074 > 38545,3730324074 (double precision format)
2005-07-12 08:57:10 = 2005-07-12 08:57:10 (string format)

Any idea where this difference comes from?

Rounding up was done with DateAdd.

VB version 6, on XP.
Boiled down code has been attached.

Making Sure The User Enters A Date In Date Format
How do I ensure a user enters text in a textbox in date format? i.e. when the user enters into the textbox it automatically has:
--/--/--
and only allows the user to entera valid date.

How To Set The Date Into Long Date Format In The Regional Settings?
how can i SET the date into long date format (regional settings)?

i want that once my form is loaded, it will automatically SET the date in the regional settings into long date format.

Getting Numbers In Date Field Into Date Format???
in my access db i have an old table and the dates were never formatted eg its just 791023 as in 23 of oct 1979 so i had to change that to get it in date format so i did this using a query

UPDATE history_date SET history_date.theDate = format([theDate]," mm/dd/yy");

like it worked and put in the slashes but the date is different
it came out 01/25/55 when the date was originally 641027
why is it changing it ???
like i tried diff format like yy/mm/dd and still the same...
confused!!please help if u know anything...

How To Tell If A Cell Contains A Valid Date
I thought this is what the IsDate function did, but apparently not.
If cell A1 contains "car", IsDate(Range("A1") is still returning true...I'm guessing this is because the cell was has the date format.

Check To See If Valid Date
Hey guys, run into a little snag and I'm wondering if someone has any ideas. I hope this is a simple fix. Basically I need to check a string to see if it meets the criteria to be a date. In other words, if I have "1/1/2004" I'd want it to validate true, but if it's "//" I'd like it to be false. I have some code running that is querying printers and getting their manufactured date, but some oddball models aren't returning valid dates and when I try to do a cdate() on the string it's obviously type mismatching, so I'd like to do a check before trying the cdate() to make sure the date is valid. Does this make sense?
Tom

Valid Date In A Text Box.
I have a text box which will hold a date value. I want the date to be stored in the format ddmmyyyy. But I want the user to be able to type in a number of styles i.e dd/mm/yy dd/mm/yyy dd-mm-yy. I also need to check that the user has not entered the date in the format mmddyy. What would be the best way of doing this?

Thanks

Paul

Valid Date In String
Hi Someone can help me ?


How Can I Found Valid Date in string


Ex. "This Date 12-12-2003" return : 12-12-2003


Thanks

Any Numeric Into A Valid Date
Hi! How do I convert any values (numeric eg. 9999 to 09/09/99) entered into a text box to a date?


Regards
JK

Valid Date Entry
VB Code:
If IsDate("Your Entry") Then    MsgBox "Valid Date Entry"Else    MsgBox "Invalide Date Entry"End If

Check Valid Date
I usually check whether the date is valid or not, I would do this:
======================
dim d as date
on error goto Date_Err
d=txtdate

Date_Err:
if err=13 then
msgbox "...."
endif
======================
But recently, I notice that this method does not work in some case. for example, if the txtdate=#01/00/00#, this method could not detect for error # 13.
Is anyone there know how to solve this problem? Is there any API functions do this?

Thank You very Much

Check If Date Has A Valid Time
Guys, anyone got a workaround to determine if a certain date have a time accompanying it?

For example "4/9/1980 5PM" should be accepted but not "4/9/1980" only...

TIA

How To Check The Value In Textbox Is A Valid Date?
i need person to enter the date in the text box ,the date will be used for a SQL query, but if the person did not input a valid date , the program will be terminated.
i have to avoid this bug , how?

PS: my date format should be MM/DD/YYYY

i was thinking to use a char arry to get the string(have not try yet), then compare the char one by one , to see if it same as my format or not,but i must write many code , i want to find a wasy way.

Testing For A Valid Date And Or Time
Better still, use the VB IsDate() function. Include your string in this function, which will return True if the string is a valid date and False if not.

Private Sub ..........

Dim MyDateString As String

....Get the date string ....

If IsDate(MyDateString) Then
MsgBox "Gosh! It's a date!"
Else
MsgBox "Sorry, fella, you got it wrong"
Endif


End Sub



This way you don't have to generate and then trap an error.

How Do You Check If A Date Entered Is Valid
Hi there how do you check if a date entered into a text box is a valid entry......

We dont want to use a date picker because they look really odd in our program, any ideas?

Rohan

Check Valid Date From A TextBox
Hi,
I am using VB6. In a text box I am inputing some date
value. I want to check if this date input into the
text box is a valid date or not. I am using the below
code.

If IsDate(txtTextBox.Text) = False Then
MsgBox "Please Enter A Valid Date...",
vbInformation
EndIf

Now if I input an invalid date into the txtTextBox say
==> 32/01/03 where 32 is the date, 01 is the month Jan
and 03 is the year 2003, it does not display the error
message. In actual, it treats 32 as the year instead
of the date.

I have even tried using the code as below but it does
not help

If IsDate(Format(txtTextBox.Text, "dd-mm-yy")) = False
Then
MsgBox "Please Enter A Valid Date...",
vbInformation
EndIf

Please note that I have always been using DatePicker
(and therefore have never faced any such difficultly)
in my projects but in this current situation I do not
want to use DatePicker. Therefore please let me know a
way out, if, when a user enters a date value into the
txtTextbox in "dd-mm-yy" format how do I check if the
date entered in a valid date?

Thanks in advance for your help.

ORA-01839: Date Not Valid For Month Specified
Hi all,

I have a problem with the following my oracle query is like this:

SELECT day FROM calendar cl WHERE
TO_DATE(TO_CHAR(cl.month||'/'||cl.day||'/'||cl.year ),'mm/dd/yyyy') >=
TO_DATE('07/01/2003','mm/dd/yyyy')

it gives me following error:
ORA-01839: date not valid for month specified

what is the problem?

I have checked for all dates in database and they are proper. there is no
invalid date like (eg: 31-6-2003 or so).

please help.

vinay

Check If Textbox Has Valid Date?
How would you perform the following without using an On Error Resume?
Code:Private Sub tbDate_Validate(Cancel As Boolean)
    If Not CDate(tbDate.Text) Then
        tbDate.Text = ""
        ' Not a valid date.
        vMsg = "Please type in a valid date."
        vTitle = "Date Not Valid"
        vButtons = vbInformation + vbOKOnly
        vResponse = MsgBox(vMsg, vButtons, vTitle)
        Cancel = True
    End If
End Sub


|
+--JDMils
|
+--VB6
+--VB Dot Net
|
+-- Navman GPS Forums @ http://forum.jdmils.com
|

Empty Date &amp; Date Format
I have in my table a field where I have now a date like
#01-Jan-2004#
But, for a specific reason, I want to delete that date and leave the field empty.
How can I do that? Is there any constant for the "empty date"?
If I try #00-00-00# I get an error.

And another question:
Is there any chance to set the date format? I don't want to depend on computer settings!!! I want to be sure that if the user will write in a text box
"02-03-2004"
this will be "02-Mar-2004" and not "Feb-03-2004"

Date Format But Not Current Date HOW?
I am new to VB. Work with VB5 Enterprise.

I think this should be simple, but I cannot figure it out:

How do I create a text-box in which the user can write a random date that is not today's date. And still keep the date format?

Example: User inputs 12122009 and I want textbox to change into: 12-12-2009 or 12:12:09 or 12-12-09 or 12:12:2009.

The change should be instant or at the latest at "lost focus".

All the examples I have found work with the current date.

Any ideas?

All the best
Svanholm



How To Get The Right Date Format After Adding A Date
Hi ,

The below is the Code in the Timer. The Purpose is to when the Time Reaches the process should done. The process is

Reading a Encrypted text from the file named ImpDate.TXT, the Text is the date and its Format Is (“MM/DD/YYYY HH:MM:SS AM/PM”).

After reading it I am storing it in a string. Then I need to add one day with Date which I get and Decrypted. Then again I will encrypt it and over write the ImpDate.TXT File.

Private Sub Timer1_Timer()

MyTime = Format(TimeValue("12:05:50 PM"), "HH:MM:SS AM/PM")
CurTime = Format(Time, "HH:MM:SS AM/PM")

If MyTime = CurTime Then

‘’ Reading the Encrypted Text from the File
    Open "C:chsImpDate.TXT" For Input As #1
    While Not EOF(1)
    Line Input #1, st
    Wend
    Close #1
   
 Secret$ = st
  Password$ = "vehiclesystem"
‘’Decrypting the Encrypted Text and add one day with it and again I have Encrypt and Store. For testing whether the one day is added or not, I write it in a file DecDate and checked.

  Call Decrypt(Secret$, Password$)
   sts = Format(st, "MM/DD/YYYY")
       Dim nFile As Integer
    nFile = FreeFile
    Open "C:chsDecDate.TXT" For Append Shared As #nFile

    Print #nFile, sts
    Close #nFile
End If
End Sub

The problem is I am getting the wrong date is coming as below

01/27/1900 12:00:00 AM

tried in various ways but not coming the correctly.

Thank you very much,
Chock.

How To Validate A Date When Date Format Is Different
How validation of date whould be done where date format is "dd/MM/yyyy" and windows date format is "MM/dd/yyyy"

Format Date In Long Date
In VBscript, i want to format date in long date like : 09/06/98 --&gt; june 9, 1998

A VB Function For Checking If A String Is A Valid Date
Is there a VB function for checking if a string is a valid date and it returns true or false?

and I also need a function that checks if a string is a valid number.

Reading Any String And Return A Valid Date
Hi,

I was wondering if anyone knows of a class or module out there that someone wrote that will take any value of time and date and convert it to a valid time and date. For example:

If I run: Debug.Print (Format("20040204", "dd/mm/yyyy"))

I get an overflow error when all I want is to have a string like so: 04/02/2004.

I need something that will just read anything that can remotely be assumed to be date or a time and return some correct value in the format I want as specified in the Format function.

Tons of thanks if anyone can help me on this.

Quote Valid For X Days, Determine Date It Expires
I'm making a program that generates quotes for a business. What I want is to be able to choose what date the quote is made and for how many days it is valid. e.g. 12 Oct 2005 - valid for 30 days. Then the next time the program is run it checks whether there are any quotes that are at or past their date and displays a message.

Is there any easyish way of calculating what date the message should pop up depending on the number of days used?

Unusual Query Problem, Getting Valid Records Based On Date Range
Let me explain the scenario

I am working on a sql server 2000 database. I have a table which stores the car rental rates in a table called 'Rental_Tariff'. Rates are different for different validity periods.
Now the structure of the table is as follows

Rental_Tariff

TarrifID numeric
CarID numeric
Applicable_Rate float
ValidFrom date
ValidTo date


Now in the front-end (which i am writing in ASP.NET) requires some functionality whereby a user will specify the date range and he should get the list of cars which have rates defined for that period. say the user preferences for dates are stored in two date variables vdate1 and vdate2

Select carid, avg(applicable_rate) from Rental_Tariff where
(vdate1 between validfrom and validto) or (vdate2 between validfrom and validto) group by carid

Consider these cases

Tariff Rates table contains the following

Car one $100 15/01/2006 - 18/01/2006
Car one $120 20/01/2006 - 31/01/2006

Car two $200 15/01/2006 - 31/01/2006

Car three $150 15/01/2006 - 19/01/2006
Car three $160 20/01/2006 - 31/01/2006

Car four $250 14/01/2006 - 16/01/2006
Car four $260 18/01/2006 - 20/01/2006
Car four $270 21/01/2006 - 29/01/2006

Now when the user wishes to see the car available between 16/01/2006 to 21/01/2006 he should get the "car two","car three"
Car one should not get listed because car one does not have rate for 19/01/2006
also car four should not get listed because car four does not have rate for 17/01/2006.

Hope i have been clear enough'
Can anyone help

Every Record Has A Date Field. I Want To Find A Date And From This Date, I Want To Read Records To E
Every record has a date field. I want to find a date and from this date, I want to read records to eof. What is the code? - Thanks

Query With Date Ranges And Return Only Closest Date To 'to Date'
I am using an access db...

I am trying to pull back due dates for credit reports for clients. I have 4 tables I am working with for this query...

    [Client_info]
    [Dispute_track_eq]
    [Dispute_track_exp]
    [Dispute_track_trans]

[Client_info] has the basic client information....ID, SSN, name, telephone_numbers, yadd yadda..
    each of the other tables hold the fields I am pulling from(other fields as well but these are the ones i need)...

    [Dispute_track_eq].eq_due_date
    [Dispute_track_exp].exp_due_date
    [Dispute_track_trans].trans_due_date

Here is my problem...
    I have variable that are set by dtpickers...'from_date' and 'to_date'. I am trying to get back each of these due dates that fall between the ranges set along with the [client_info] data linked by the SSN field. The problem is that sometimes these clients will have multiple due_dates(multiple rows) between the range. What the end result needs to be is this, I need to only have one record to come back with one of each due_date from each table, but only give me back the closest due_date to the 'to_date'(set by dtpicker) as well as the data from the [Client_info] table. And if there are no records for one or two but not the thirs field, an empty fields is ok(using a datagrid). But I can only pull back one row with the [client_info] fields, and one of each of the 3 due date fields. I have a query already but it doesnt even come close to working, it gives me many duplicates and doesnt give me the closest due_date to the 'to_date'.

Here is my query, but it doesnt work. Any help would be greatly appreciated, I am in dire need of help on this one.

Code:Private Sub Command4_Click() '***Due dates report grid date
    to_date = dt2.Value
    from_date = dt1.Value
    If from_date = vbNull Then
            MsgBox "Please select a FROM DATE"
            Exit Sub
        ElseIf to_date = vbNull Then
            MsgBox "Please select a TO DATE"
            Exit Sub
    Else
    Dim ID_new As String
    Dim cn As ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim strSQL As String
    Dim ID_pass As String
    Dim active As String
    
    active = "Active-Negotiations"
   
    Set rs = New ADODB.Recordset
    
    
        strSQL = "Select" & vbNewLine
        strSQL = strSQL & " [client_info].[FirstName], [client_info].[LastName], [client_info].[HomePhone], [client_info].[MobilePhone], [client_info].[Client_status], [client_info].[Category], [client_info].[Appt_notes],[client_info].[Appt_date],[client_info].[Appt_date_time], " & vbNewLine
        strSQL = strSQL & " [dispute_track_eq].[eq_due_date], [dispute_track_exp].[exp_due_date], [dispute_track_trans].[trans_due_date]" & vbNewLine
        strSQL = strSQL & " FROM (dispute_track_exp INNER JOIN (dispute_track_eq INNER JOIN client_info ON [dispute_track_eq].[SSN] =[client_info].[SSN]) ON [dispute_track_exp].[SSN] =[client_info].[SSN]) INNER JOIN" & vbNewLine
        strSQL = strSQL & " dispute_track_trans ON [client_info].[SSN] =[dispute_track_trans].[SSN]" & vbNewLine
        strSQL = strSQL & " Where (dispute_track_trans.trans_due_date > #" & from_date & "# And" & vbNewLine
        strSQL = strSQL & " dispute_track_trans.trans_due_date < #" & to_date & "#)" & vbNewLine
        strSQL = strSQL & " OR (dispute_track_eq.eq_due_date > #" & from_date & "# And" & vbNewLine
        strSQL = strSQL & " dispute_track_eq.eq_due_date < #" & to_date & "#)" & vbNewLine
        strSQL = strSQL & " OR (dispute_track_exp.exp_due_date > #" & from_date & "# And" & vbNewLine
        strSQL = strSQL & " dispute_track_exp.exp_due_date < #" & to_date & "#) AND NOT NULL"


    Set cn = New ADODB.Connection
    With cn
           .Provider = "Microsoft.Jet.OLEDB.4.0"
           .ConnectionString = "Data Source= " & db & " "
           .open
    End With
    
    Set rs = New ADODB.Recordset
    With rs
        .ActiveConnection = cn
        .CursorLocation = adUseClient
        .CursorType = adOpenStatic
        .Source = strSQL
        .open
    End With
        
        If rs.RecordCount = 0 Then
            MsgBox "Sorry, no one matched that status, try again", vbOKOnly, "Credit Matrix"
            Set DataGrid1.DataSource = rs
        Else
            Set DataGrid1.DataSource = rs
    
        End If
        End If

    I would be forever in your debt for helping me as I am almost out of hair....FROM PULLING IT OUT!!
    



Edited by - ronmegga on 4/1/2004 5:26:03 PM

Grouping By Date Where Date Field Is Date/time
I have an SQL7 database storing datetime data, and totaliser reading, new records are added every 5 minutes.

I have written the following sql to give me the the min and max totaliser reading for each day - which works fine - except that the resultant Date field is a text field not a date field so the order statement generates an incorrect listing if the data selected sarts in one month and ends in the next, eg.

select left(Date, 12) as Date, Min(Reading) as Day_Start, Max(Reading) as Day_End from Steam where tag_no = 2 and (Date <= '24-November-2005 00:00:00' and Date >= '22-October-2005 00:00:00') Group By left(Date, 12) order by Date asc

Is there another function I can use to extract just the date from the date/time field as a date data type?

I cannot alter the database as its structure is predetermined by the remote field device supplying the data.

Format String To Date Format And ....
Question one,
If a user types 4/5/03 into a textbox, how do I format this to this date style - 04/05/03?

They may type it as I want, or they may type it like the above, so I need to make sure before I do part two, below, that it is in the correct format.

Part two,
How can I compare the month part of the date (05) with a Month name (e.g. September) in a Flexgrid. I know I can use the textmatrix to get the name of the month. Would the best way be to use a select case to compare the months?

Format String To Date Format And .....
Question one,
If a user types 4/5/03 into a textbox, how do I format this to this date style - 04/05/03?

They may type it as I want, or they may type it like the above, so I need to make sure before I do part two, below, that it is in the correct format.

Part two,
How can I compare the month part of the date (05) with a Month name (e.g. September) in a Flexgrid. I know I can use the textmatrix to get the name of the month. Would the best way be to use a select case to compare the months?





Edited by - andy99 on 9/25/2003 9:57:39 AM

Format Date
Hi !

I have a problem with formatting my date.
I'm currently using VB (access)

The scenario goes like this:

I'll get a value from the textbox and store it as a global value.
Before performing a search using SQL, I'll have to format the date to mmddyyy (instead of ddmmyyyy).
But after formating, my date still appear as ddmmyyyy. Why is this so? Is there any other way to solve it?

Below is some of my codes:

'--- Assign value to global var ---
ViewModeAssdate = Forms![View Assessment]!Text268.Value
'--- format date to mmddyyyy---
ViewModeAssdate = Format(ViewModeAssdate, "mm/dd/yyyy")

thanks alot!

Date Format
We are trying to ensure that our spreadsheets are set to U.S. Format but inserting a routing at start-up to check and pop up a box. I haven't been able to get this code to work. I think the us format is 0, but the code won't run. Any ideas?

Sub Check_Date()

Dim Date_Setting As Integer


If Date_Setting <> 0 Then
MsgBox "The regional settings of your pc must be American Style Month-Day-Year to open this worksheet"
Call Closeit
Else: End If

Date Format
Is there a way to format the date so it reads (For instance today is July 8, 2004, but I just want the number of the day to display in this case it would be 8, but I want it to read or automatically add the th to the end of it. So the date in the cell would say 8th.) Is there something I can do to add that on the end. I would need it for rd, th, st, and nd.

Date Format
hi all,

I am trying date format if the user enters the date as 03/01/2006, the program should convert it to (2006,03,01,00,00,00), iam trying to use datepart but wasnt successful.... need ur inputs on this.

Date Format As Mm/dd/yy?
I am using Microsoft Access VB to update records in a WRQ Reflection application and am having trouble updating a Date field. In the Reflection Application, the field I ap trying to update will only allow a date in the mm/dd/yy format. In my Access table, even though my date field is formatted as mm/dd/yy, when VB tries to update Reflection date field, it enters it as mm/dd/yyyy and my program errors out.

How can I format the variable I am using for the date in VB as mm/dd/yy?

Date Format
How can I get Excel to display the date in standard text format "August 12, 2003" instead of 12-Aug-03?

My code is:


Code:
xlWorksheet.Cells(6, 5) = "August " + sDate + ", 2003"

Need Help - Date Format
This is the first time I have ever been exposed to any type of code and I need help.

I am doing an assignment for uni (a telephone directory) and need to display all my contacts as a Control Break Report by month of Birth.

Currently my txt file contains a date in this format :

30/9/1967

and in order to in order to display the contacts by month of birth, I need to change the format to something like this:

September 30 1967

If someone can help asap, that would be great as I am running out of time.

Thanks
Margaret

Copyright © 2005-08 www.BigResource.com, All rights reserved