how to get the first day in a month

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

how to get the first day in a month

shivax
Hello,
I have a serial date
I want to know the first day of the month of the serial date



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: how to get the first day in a month

Doug Stewart-4


On Wed, Jul 4, 2018 at 7:43 AM, shivax <[hidden email]> wrote:
Hello,
I have a serial date
I want to know the first day of the month of the serial date



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html



did you read the help for datestr?
help datestr


--
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

RE: how to get the first day in a month

Allen.Windhorn-3
On Wed, Jul 4, 2018 at 7:43 AM, shivax <[hidden email]> wrote:

> I have a serial date
> I want to know the first day of the month of the serial date

Example:

>> datestr(737255)
ans = 14-Jul-2018  # Could just change the '14' to '01' here, but...
>> foo = datevec(737255)
foo =

   2018      7     14      0      0      0

>> foo(3) = 1   # This is easier
foo =

   2018      7      1      0      0      0

>> datenum(foo)
ans =  737242
>> datestr(foo)
ans = 01-Jul-2018
>> [N, S] = weekday(datenum(foo))
N =  1
S = Sun

Regards,
Allen