Thursday, March 29, 2012

Configure datepart's first day of the week

Hello,

I would like to configure the first day of the week as monday. I know how to set it on sql using set datefirst 1.

But i do that in the server that im working and on the report my week is wrong. It isnt using monday has the initial day, but sunday.

Im using the datepart on the expression of a field, the RS probably is getting another configuration, why? Is he picking it up from the VB engine? If so how can i configure?

Is he picking up from another db? What is the db that he normally gets it from?

If the thing that i did is almost right but it doesnt configure the server but only my session, how can i configure the db/server properlly.

Thank you

Saying this in another way.

How can i configure the datefirst to have permanently the value 1.

Thank you

|||

When using DatePart from the expression box you are not using the settings defined by the SQL connection i.e. datefirst 1, you are using the .NET framework.

The DatePart method has overloads to which you can pass additional parameters to set the first day of the the week and the the first week of the year. Search help for "DatePart method".

I used the following in the expression box and it works fine:

=DatePart("w", Now, FirstDayOfWeek.Monday)

|||Alternatively if you want to use the datefirst option of the SQL connection the I suggest doing the datapart calculation in the SQL query and returning it in the dataset.|||

Thanks this does the job, i dont know why i didnt saw the other arguments of the function.

Thanks

|||

hey man,

try this - http://www.vsmsdn.com/devnet/Thread.aspx?ThreadID=28

hope this will help.

cheers.

sqlsql

No comments:

Post a Comment