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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

modify dates in database 1

Status
Not open for further replies.

ethan1701

Technical User
Jan 10, 2003
16
Hi,
I have a database, were dates were stored impropperly. When I sent to it july 1st, it saw it as January 7th (7/1 or vice-versa). I managed to fix the bug causing this, but now I have a few hundred records to fix.
I'd appreciate an yadvice on the best way to fix the dates, using either the Access 97 DB tools or ASP code (VB).
some of the tables that need to fixed have two wrong columns (activityDate and TimeStamp).

Thanks,
-Ethan
 
An Access or sql query would do this.

Update mytable set mydate = dateserial(year(mydate), day(mydate),month(mydate))

Dateserial takes three arguments in the sequence year, month, day, so if the date value was stored incorrectly (and not just formatted incorrectly) this will fix it.

It sounds as if you may have already done something like this but if not, then at least do a temporary change to the table to format the date field as a long date and make sure that you are truly getting the wrong values displayed when you look at the table.
 
That worked like a charm! Thanks!

oh, and who else thinks there are too many date related functions? :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top