Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Date Conversion

Hi

I am reading the csv file which has the date column.  Loading this data into the script.  When loading i am getting the Year, Month from this date.   But the values comes out as NULL.

The actual date fields has value. But when converting the values are not getting populated.  I did the Date# conversion also.

Can someone help on what could be the issue.

Thanks

Ramesh

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

Converting to a date

LOAD

InvoiceID,

PayerAccountId,

LinkedAccountId,

RecordType,

RecordID,

date#(BillingPeriodStartDate,'M/D/YYYY h:mm') as BillingPeriodStartDate,

date#(BillingPeriodEndDate,'M/D/YYYY h:mm') as BillingPeriodEndDate

INLINE [

    InvoiceID,PayerAccountId,LinkedAccountId,RecordType,RecordID,BillingPeriodStartDate,BillingPeriodEndDate

    234,22312314,1231200001,LinkedLineItem,36012341200,9/1/2013 0:00,9/30/2013 23:59

];

View solution in original post

7 Replies
shree909
Partner - Specialist II
Partner - Specialist II

Hi could you please post a sample of file.

or the  data column values from the csv file .

that will be easy to figure it out..

Mostly  u need to use the  Date(Date#( 'ur date filed column,/'MM/DD/YYYY'),'  to convert to the desired format') as Date

This should solve ur issue  or load a sample of data...

tresesco
MVP
MVP

May be your field reference is not being correct. Try 'File Wizard' to load the data and see if you can find the data at the right place.

Not applicable
Author

Hi Ana

Here is the script

ASW_MAIN:

LOAD

BillingPeriondStartDate,   This has value 9/1/2013 00:00

date#(BillingPeriodStartDate,'M/D/YYYY') as billstartdate, This is also getting the value as 9/1/2013
Year(BillingPeriodStartDate) as BillingYear,This has no value
Month(BillingPeriodStartDate) as BillingMonth, This has no value
BillingPeriodEndDate, This has value 9/30/2013 23:59

LOAD
Min(BillingPeriodStartDate) as MinDate,
Max(BillingPeriodEndDate) as MaxDate
Resident AWS_MAIN;

Both the MinDate and MaxDate are getting null values.   I checked the columns for null values and none of them have null values.

Thanks

Ramesh

Clever_Anjos
Employee
Employee

It hard to think a reason without knowing your data, please post a line of your csv file

shree909
Partner - Specialist II
Partner - Specialist II

Hi Use this

This should work

Year(Floor(date#(BillingPeriodStartDate,'M/D/YYYY')))as BillingYear,
Month(Floor(date#(BillingPeriodStartDate,'M/D/YYYY'))) as BillingMonth,


If this doesn't work load a sample file with data or csv file..

Not applicable
Author

Hi

Here is the data

InvoiceID,PayerAccountId,LinkedAccountId,RecordType,RecordID,BillingPeriodStartDate,BillingPeriodEndDate

234,22312314,1231200001,LinkedLineItem,36012341200,9/1/2013 0:00,9/30/2013 23:59

Thanks

Ramesh

Clever_Anjos
Employee
Employee

Converting to a date

LOAD

InvoiceID,

PayerAccountId,

LinkedAccountId,

RecordType,

RecordID,

date#(BillingPeriodStartDate,'M/D/YYYY h:mm') as BillingPeriodStartDate,

date#(BillingPeriodEndDate,'M/D/YYYY h:mm') as BillingPeriodEndDate

INLINE [

    InvoiceID,PayerAccountId,LinkedAccountId,RecordType,RecordID,BillingPeriodStartDate,BillingPeriodEndDate

    234,22312314,1231200001,LinkedLineItem,36012341200,9/1/2013 0:00,9/30/2013 23:59

];