How to Convert String to Date in this Context
Hi!
I have the following code:
- SELECT concat(year(sd."Doc Date"), '-', if(length(month(sd."Doc Date")) = 1, '0', ''), month(sd."Doc Date")) as Month, sd."Source of Rebill", Count(sd."Invoice #") as 'Number of Invoices',
- Count(sd."Credit Memo # (if app)") as 'Credit Memo' , (Count(sd."Credit Memo # (if app)")/Avg(ic."Number of Invoices")*100) as 'Credit Memo %',
- (count(sd."Credit Memo # (if app)")/count(sd."Invoice #"))*100 as '% of Billing Errors'
-
- FROM "Sales Detail" sd
- inner join "Invoices Count per Month" ic on concat(year(sd."Doc Date"), '-', if(length(month(sd."Doc Date")) = 1, '0', ''), month(sd."Doc Date")) = ic."Month"
-
- group by concat(year(sd."Doc Date"), '-', if(length(month(sd."Doc Date")) = 1, '0', ''), month(sd."Doc Date")), sd."Source of Rebill"
Question:
The first column comes out as a text string. How do I convert it to a date field? I tried using str_to_date() but I could not get it to work. Any help would be GREATLY appreciated. Thanks!