Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Date Add Function

Author  Topic 

JDP12345
Starting Member

4 Posts

Posted - 2011-06-20 : 16:48:22
Hello>

I have a date statement that I need to display the day of the week.

=DateAdd("h",-4,DateAdd("s",CInt(Left(Fields!SubmittedDate.Value,10)),"1970-01-01 00:00:00")) & " EST"

CURRENT RESULT: MM/DD/YYYY 4:10:44 PM EST

NEED: Monday MM/DD/YYYY 4:10:44 PM EST

Is there any way to tweak the DateAdd code to allow for Monday

The Submitted Date is NVARCHAR(10) and looks like this when it returns values in the table

1038600098039

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-20 : 17:07:31
While you can certainly get this output using T-SQL, you should instead do this formatting in your application as this is a presentation issue.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

JDP12345
Starting Member

4 Posts

Posted - 2011-06-20 : 17:12:04
Thanks Tara for getting back to me.

This is an expression that I'm using in an SSRS report.

Is there another way to interpret the statement to produce Monday MM/DD/YYYY 4:10:44 PM EST

Thanks
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-06-20 : 17:18:09
In Microsoft's t-SQL you can use the datename function
select datename(weekday,getdate())

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

JDP12345
Starting Member

4 Posts

Posted - 2011-06-20 : 17:25:45
Thanks for the post but datename is not recognized as a SSRS expression.

Go to Top of Page

JDP12345
Starting Member

4 Posts

Posted - 2011-06-20 : 17:50:04
I have resolved the issue with this statement
=DateAdd("h",-4,DateAdd("s",CInt(Left(Fields!SubmittedDate.Value,10)),"1970-01-01 00:00:00")).ToString("dddd MM/dd/yyyy hh:mm:ss tt") & " EST"
Go to Top of Page
   

- Advertisement -