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

Date part only of datetime field in ms access

Status
Not open for further replies.

achick

Programmer
May 23, 2007
66
US
I would like to know how I can get date part only of date time field in ms access.
I am trying to import the file into SAS but the time stamp also comes. I tried to export to txt file, still the time stamp shows up.
 
WHen you pass the date, use the FORMAT function to cast it as a string.
Code:
Format(DateCol, "yyyymmdd")

Most systems should not have any trouble recognizing the date in that particular format (or you can use another if it suits you)

HOpe this hepps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Thanks for replying.
I created another columns and tried to update it.
update table1 set new_col = format(date_col, "mm/dd/yyyy")
Then tried to export to text file the whole table. but it did not help.
 




Hi,

"...but it did not help."

Could you be more specific. WHAT?

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
I am still getting time format exported to text file instead of just date part for the new date column I created
 



So are you saying that new_col has Date & Time?

Did you make that column data type, TEXT?

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Thanks for the reply. When I changed to txt format, I can just get the date part. Then I imported into SAS and the data type is string.

I now figured out a way in SAS how to change and specify format for date field during import without creating a new column in access.

One thing I still do not know how to do is, how can we store just date part in access in a date/time field. If that can be done it is much easy when tranferring files from one software to another.
Does access always store date as date/time internally?
 
MS Access and all other databases that I know store dates as datetimes. Even when you enter only a date, it will return this date as a datetime, where the timepart is 00:00:00

The function datevalue returns only the datepart of a string that represents a date(time) but also of a real datetime.

Try
Code:
  Mydate = DateValue(now())
 



In DateTime is just a NUMBER, like right now in Texas is 39226.29741. The Integral part of the number is DATE, while the fractional part is TIME.


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top