DATEADD with DATEPART

josieguida02

New Member
Joined
Mar 23, 2009
Messages
13
I am trying to group records 3 ways in Visual Studio for an excel spreadsheet, by hour, week and month. I have currently have to break apart the date column with a dateadd statement, as my columns that have the times contain a unix date time. I need to make a new column with the dateadd and datepart statements combined.

When I add the datepart statement to the equation the the query fails, and I have to end the task.

Here is an example of the what I currently do break about the unix timestamp in my Microsoft SQL 2008 Database.

DATEADD
(ss, HS_Request.dtGMTOpened, '19700101') AS [Date Open]


 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
This is what I found to work.


DATEADD(ss, - 25200, DATEADD(ss, HS_Request.dtGMTOpened, CONVERT(DATETIME, '1970-01-01 00:00:00', 102))) AS [Date Opened]
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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