= c(9,1,15,4,5,17,18))
df2$Date<-as.Date(df2$Date)
cbind(df2, sqldf("select strftime( '%m', Date) from df2"))
Data formatted according to your example but **not** changed to Dates,
correct result
df3 <- data.frame(Date =
c("2013-05-25","2013-05-28",
First of all I would like to say thanks to everyone for sharing valuable
information, now I can able to do that if date column datatype is “Factor”
but by default the date column datatype is “POSIXct” in R ,so whenever I
want apply stfrtime function with sqldf package ,do I need to convert the
date
On 16 Sep 2016, at 15:23 , PIKAL Petr wrote:
> Hi Peter
>
> The devil is in detail
>
> Data from OP had different format and was transferred to Date object by
> as.Date, which results in incorrect values (and NA if not transferred)
> df <- data.frame(Date =
> c("2013/05/25","2013/05/28","201
IKAL Petr wrote:
>>>
>>> > Hi
>>> >
>>> > Most probably there is some syntactic suger how to correctly
>>formulate sql
>>> query.
>>> >
>>> >> sqldf('select Date, strftime("Date", "%m") fr
), Quantity = c(9,1,15,4,5,17,18))
>cbind(df3, sqldf("select strftime( '%m', Date) from df3"))
>
>so sqldf is a bit peculiar about required input values and does not
>know how to handle Date objects.
>
>Cheers
>Petr
>
>
>> -Original Message---
013-06-05","2013-06-07"), Quantity = c(9,1,15,4,5,17,18))
cbind(df3, sqldf("select strftime( '%m', Date) from df3"))
so sqldf is a bit peculiar about required input values and does not know how to
handle Date objects.
Cheers
Petr
> -Original Message-
&
; format(sqldf("select Date from log"), "%m")
>
> This one however works.
>
> Cheers
> Petr
>
> From: Manohar Reddy [mailto:manu.redd...@gmail.com]
> Sent: Friday, September 16, 2016 11:55 AM
> To: PIKAL Petr
> Cc: R-help
> Subject: Re:
:
error in statement: no such function: format
>
format(sqldf("select Date from log"), "%m")
This one however works.
Cheers
Petr
From: Manohar Reddy [mailto:manu.redd...@gmail.com]
Sent: Friday, September 16, 2016 11:55 AM
To: PIKAL Petr
Cc: R-help
Subject: Re: [R] stf
Hi Petr,
Thanks, For me also it’s working fine when I directly used that function
but when I call strftime function through sqldf package it’s returning NA
values (PFA) ,but my requirement is I need to do that only sqldf as I’m
writing some “T sql ” queries against on the dataset.
Manu.
On
Hi
Hm
> format(log$Date, "%m")
[1] "05" "05" "05" "06" "06" "06" "06"
> strftime(log$Date, "%m")
[1] "05" "05" "05" "06" "06" "06" "06"
>
works for me.
Just a blind guess, is an object date somwhere in your environment?
Cheers
Petr
> -Original Message-
> From: R-help [mailto:r-help-bo
Jeff,
Thanks,my question is when I’m using strftime function in sqldf package
it’s not returning the results which has supposed to return ,now how can I
get the excat month from my sample data with strftime function through
sqldf package ?
Manu.
On Fri, Sep 16, 2016 at 11:32 AM, Jeff Newmi
This question is missing pieces... the example is incomplete.
--
Sent from my phone. Please excuse my brevity.
On September 15, 2016 9:35:45 PM PDT, Manohar Reddy
wrote:
>Hi ,
>
>
>
>I have data something looks like below (or PFA), but when I’m
>extracting
>month using *strftime* function th
12 matches
Mail list logo