Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Getting the month of a date

Hi,

I need to get the month of a date into a SQL SELECT statement. I want the numeric value, thus 1, 2, ,,,, 11, 12 not the brief month name.

Thanks

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hello,

The Month() function returns a dual value, so with

Num(Month(DateField)) AS MonthNo


You will get the month number.

Hope that helps.

View solution in original post

3 Replies
Miguel_Angel_Baeyens

Hello,

The Month() function returns a dual value, so with

Num(Month(DateField)) AS MonthNo


You will get the month number.

Hope that helps.

Anonymous
Not applicable
Author

Hi,

I have tried you solution  in SQL select, but it says Num is not a valid funtion, and  even I dont write Num, and writing like Month(datefield) as month, it gives month number, but I need month name  in  Jan, feb, march etc. please help.

Miguel_Angel_Baeyens

Hi Shubham,

The above is meant to be used in a LOAD statement like this:

// QlikView is case sensitive: fields must be spelled as the RDBM/ODBC driver returns them

Data:

LOAD CustomerID,

     Num(Month(DateField)) AS NumMonth,

     Month(DateField) AS NameMonth,

     DateField;

SQL SELECT CustomerID,

     DateField

FROM Database.Table;

Hope that helps.

Miguel