Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dates!

Status
Not open for further replies.

Russie

Programmer
Dec 24, 2000
104
US
Hi

The code below works well apart from DatePosted = 12/09/02 and when it inserts this date into the table it reads 09/12/02.

Public Function addDate()
Dim conDatabase As ADODB.Connection
Dim strSQL As String
Dim SumOfValue As Currency

Set conDatabase = CurrentProject.Connection

strSQL = "INSERT INTO tblDateRun (DateRun) VALUES (# " & DatePosted & " #);"

conDatabase.Execute strSQL

conDatabase.Close
Set conDatabase = Nothing

I have my regional settings set to UK - English and the date format in my table is dd-mm-yy.

Any help appreciated.
 
Hi,
Access stores this data internally in the mm-dd-yy format. So you can use the format function to display the date in the format you wish. So you can use format as belw:

Me.txtDate = Format(rs.Fields("DateRun"),"dd-mm-yy")

This will display the date in the specified format. Hope it helps. Let me know what happens.
With regards,
PGK
 
SQL always uses American date formats, so you will need to cahnge it to:

strSQL = "INSERT INTO tblDateRun (DateRun) VALUES (# " & format(DatePosted,"mm/dd/yy") & " #);"

Ben


----------------------------------------
Ben O'Hara
----------------------------------------
 
Hi pgk and oharab.

I got it to work in a fashion so thanks to you both but the format that places the date in the correct format in the table is:

yyyy/mm/dd ???????????

strSQL = "INSERT INTO tblDateRun (DateRun) VALUES (# " & Format(DatePosted, "yyyy/mm/dd") & " #);"

I'm not sure why this works.

Anyone got any ideas?.., oh and thanks very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top