Strip time from date

PCRIDE

Well-known Member
Joined
Jan 20, 2008
Messages
907
Hi, I have a column in SQL actually, assuming the commands would be the same in Access. I have a Created Date field and its Date and Time.

I have my basic query

Select * FROM DATABASE name
[Column Names],
[Column Names],
[Column Names],
[Created Date]

How do I write the query to format the date as Date without the time using

a) select DATEADD(dd, DATEDIFF(dd, 0, getdate()), 0)

or

CAST(FLOOR(CAST(getdate() AS FLOAT)) AS DATETIME)

??
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Let me clarify, I need the Output of the Created Date field to be only the Date to use in Reporting Services as Filters.
 
Upvote 0
What is the default value for CreatedDate? Is it Now() or Date()?

Just saw the earlier post -- crossed in the ether.
What was the solution?

Denis
 
Upvote 0
I used

Select CAST([Created Date] As Date) As [Created Date]

and just had it between several other fields and it worked perfect.
 
Upvote 0
However when using a String i.e str@CreatedDate in Reporting Services to create a Parameter for filtering my report, it still didn't remove the time from date, it only worked in the query result in SQL or Reporting Services (VS 2008)

So still trying to figure that one out. I probably need to create a function that strips the time from the date and process the data as an additional column. ie Date2
 
Upvote 0
Maybe you could use INT or similar (in Access I typically use CLng to get the day portion of a date)

Denis
 
Upvote 0
I typically use Format([fieldname], "Date format code here") as MyDateColumn

I.e. Format([thedatetime], "MM/DD/YYYY")
 
Upvote 0
If it is within Access (and not an ADP), even with SQL Server linked tables, you can use

DateValue([thedatetime])

as another alternative.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,282
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top