DATEADD with DATEPART

josieguida02

New Member
Joined
Mar 23, 2009
Messages
11
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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

josieguida02

New Member
Joined
Mar 23, 2009
Messages
11
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]
 

Forum statistics

Threads
1,136,354
Messages
5,675,291
Members
419,559
Latest member
BraytonM

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
Top