Libre
been around a little
- Local time
- Today, 15:22
- Joined
- May 3, 2007
- Messages
- 681
I have tables that have a Date/Time data field.
I've used the general date format, so the field looks like:
5/4/2006 1:35:29 PM
I've added a new column I call ShortDate, and I've specified the short date format. I want this column to just have the date without the time:
5/4/2006
I want to convert all the legacy data and write the short date to this column.
I've written a loop that looks like:
Set rst = CurrentDb.OpenRecordset("tblSalesLog")
Dim dShortDate As Date
If rst.RecordCount > 0 Then
rst.MoveFirst
Do Until rst.EOF
dShortDate = rst![SaleDate]
rst.Edit
rst![SaleDateShort] = dShortDate
rst.Update
rst.MoveNext
Loop
MsgBox ("done")
End If
It looks like it works, because only the date without the time is in the column. But when you click in the field, the long date format with the time pops up, so the time is still in there.
The Length method might work, but all the dates are different lengths:
1/1/2006; 11/12/2005; etc
I do notice there is a space between the date and the time. Maybe I can use that with the Instr command?
Suggestions?
I've used the general date format, so the field looks like:
5/4/2006 1:35:29 PM
I've added a new column I call ShortDate, and I've specified the short date format. I want this column to just have the date without the time:
5/4/2006
I want to convert all the legacy data and write the short date to this column.
I've written a loop that looks like:
Set rst = CurrentDb.OpenRecordset("tblSalesLog")
Dim dShortDate As Date
If rst.RecordCount > 0 Then
rst.MoveFirst
Do Until rst.EOF
dShortDate = rst![SaleDate]
rst.Edit
rst![SaleDateShort] = dShortDate
rst.Update
rst.MoveNext
Loop
MsgBox ("done")
End If
It looks like it works, because only the date without the time is in the column. But when you click in the field, the long date format with the time pops up, so the time is still in there.
The Length method might work, but all the dates are different lengths:
1/1/2006; 11/12/2005; etc
I do notice there is a space between the date and the time. Maybe I can use that with the Instr command?
Suggestions?