View Single Post

   
  #5 (permalink)  
Old 03-06-2008, 03:04 PM
Luuk
 
Posts: n/a
Default Re: Equivalent of MSSQL function DateFirst in MYSQL.

Hetal schreef:
> Hi Luuk.
>
> Can you please try running this query and check what the output is.
> Just to brief up, it will return the day of week.
>
> Select DATEPART(WeekDay, GetDate())
>
> And then try running this query and see what the day of week shows up
> as .
>
> Set DateFirst 2
> Select DATEPART(WeekDay, GetDate())
>
> The output of first query will differ from the output of second query.
> So my question here is, do we have something similar in MySQL that
> will let us have the functionality similar to "Set DateFirst 2"
> statement?
>
> Thanks,
> Hetal.
>
> On Mar 5, 10:46 am, Luuk <L...@invalid.lan> wrote:
>> Hetal schreef:
>>
>>> Hi..
>>> There is a function in MSSQL that sets you set what the first day of
>>> the week should be. For e.g. if i say Set DateFirst = 1, the first day
>>> of the week is set to Monday. If DateFirst = 2, then first day of the
>>> week is set to Tuesday.
>>> I would like to do something similar in MySQL but i am unable to find
>>> any equivalent function in MySQL. Your help will be very much
>>> appreciated.
>>> Thanks,
>>> Hetal.

>> I do think that there's no such function,
>> as, in my opninion, such a function should not even exist in MSSQL,
>> because the first day of the week had nothing to do with databases,
>> its an agreement between some people stating on which day the week starts
>>
>> see i.e.:http://en.wikipedia.org/wiki/ISO_week_date
>> A date is specified by the ISO year in the format YYYY, a week number in
>> the format ww prefixed by the letter W, and the weekday number, a digit
>> d from 1 through 7, beginning with Monday and ending with Sunday. For
>> example, 2006-W52-7 (or in compact form 2006W527) is the Sunday of the
>> 52nd week of 2006. In the Gregorian system this day is called 31
>> December 2006.
>>
>> --
>> Luuk

>


i do understand your question, but i find it dumb to have this option
available in a database.

because i believe that the first day of the week has nothing to do with
a database, so any statement like 'Set DateFirst 2' is useless.

and you can read all about the week functions available in MySQL at:
http://dev.mysql.com/doc/refman/5.0/...functions.html


mysql> Select DATEPART(WeekDay, GetDate())
-> ;
ERROR 1054 (42S22): Unknown column 'WeekDay' in 'field list'
mysql>


--
Luuk
Reply With Quote