Top Forums UNIX for Beginners Questions & Answers How to get first & last day of a month from current date? Post 303041727 by RudiC on Monday 2nd of December 2019 04:45:18 PM
Did you look into the helpful links at the bottom of this page under "10 More Discussions You Might Find Interesting"?

Howsoever, for your first question, try

$ date --date='07/20/2019' +"%Y-%m-01"

, and for the second,

$ date -d"$(date --date='07/20/2019 +1month' +"%Y-%m-01") -1sec" +%F

These 3 Users Gave Thanks to RudiC For This Post:
Test Your Knowledge in Computers #574
Difficulty: Medium
The process of allocating and deallocating memory is generally referred to as memory swapping.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

delete files one day old in current month only

i want to delete files that are one day old condition is files should be of current month only ie if iam running script on 1 march it should not delete files of 28 feb(29 if leap year :-)} any modifications to find $DIR -type f -atime +1 -exec rm -f{}\; (4 Replies)
Discussion started by: maverick
4 Replies

2. Shell Programming and Scripting

single digit for day and month on date

hi all, how do i format the date command so it displays day and month in single digits i.e 8 instead of 08 ?? am using the command (in a ksh) : date +%D output i get is 10/08/08 thanks in advance. (5 Replies)
Discussion started by: cesarNZ
5 Replies

3. Shell Programming and Scripting

needs to display month for previous day date

Hello, I wanted to display the month for previous day date. Like, today date is 18-Nov-2008. So the previous date is 17-Nov-2008. The output should be November. If the today date is 1-DEC-2008, then output should be NOVEMBER. If the today date is 1-JAN-2008, then output should be DECEMBER.... (4 Replies)
Discussion started by: govindts
4 Replies

4. UNIX for Dummies Questions & Answers

print previous month (current month minus 1) with Solaris date and ksh

Hi folks month=`date +%m`gives current month Howto print previous month (current month minus 1) with Solaris date and ksh (7 Replies)
Discussion started by: slashdotweenie
7 Replies

5. Shell Programming and Scripting

current date - one month in AIX

Hi, i unable to get the last month date in AIX. current date - one month Based on the forums tried but did not find the relevent information. Any help grealy appriciated. Thanks Suri. (3 Replies)
Discussion started by: onesuri
3 Replies

6. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

7. Shell Programming and Scripting

Help with getting last date of previous month and first date of previous 4th month from current date

I have requirment to get last date of previous month and the first date of previous 4th month: Example: Current date: 20130320 (yyyymmdd) Last date of previous month: 20130228 (yyyymmdd) First date of previous 4th month: 20121101 (yyyymmdd) In my shell --date, -d, -v switches are not... (3 Replies)
Discussion started by: machomaddy
3 Replies

8. AIX

AIX - Get next month from current date

As said in object, how can i obtain that? In linux i use date -d "1 month" +"%m%Y". Thanks i advance. (8 Replies)
Discussion started by: fabfisc
8 Replies

9. Homework & Coursework Questions

How to minus 2 month from current date?

I am running a script in ksh to get the 2 months back date from system date.The below code is giving correct date output from putty command prompt.But while running the script is .ksh file it is giving the error below.Please suggest. ; d=a; y=a m-=num while(m < 1) {m+=12; y--}... (1 Reply)
Discussion started by: hini
1 Replies

10. UNIX for Beginners Questions & Answers

Replace date in file every day with current date

I Have text like XXX_20190908.csv.gz need to replace Only date in this format with current date every day Thanks! (1 Reply)
Discussion started by: yamasani1991
1 Replies
HTML::FormHandler::Field::Date(3pm)			User Contributed Perl Documentation		       HTML::FormHandler::Field::Date(3pm)

HTML::FormHandler::Field::Date - a date field with formats VERSION
version 0.40013 SUMMARY
This field may be used with the jQuery Datepicker plugin. You can specify the format for the date using jQuery formatDate strings or DateTime strftime formats. (Default format is format => '%Y-%m-%d'.) d - "%e" - day of month (no leading zero) dd - "%d" - day of month (two digit) o - "%{day_of_year}" - day of the year (no leading zeros) oo - "%j" - day of the year (three digit) D - "%a" - day name short DD - "%A" - day name long m - "%{day_of_month" - month of year (no leading zero) mm - "%m" - month of year (two digit) "%m" M - "%b" - month name short MM - "%B" - month name long y - "%y" - year (two digit) yy - "%Y" - year (four digit) @ - "%s" - Unix timestamp (ms since 01/01/1970) For example: has_field 'start_date' => ( type => 'Date', format => "dd/mm/y" ); or has_field 'start_date' => ( type => 'Date', format => "%d/%m/%y" ); You can also set 'date_end' and 'date_start' attributes for validation of the date range. Use iso_8601 formats for these dates ("yyyy-mm- dd"); has_field 'start_date' => ( type => 'Date', date_start => "2009-12-25" ); Customize error messages 'date_early' and 'date_late': has_field 'start_date' => ( type => 'Date, messages => { date_early => 'Pick a later date', date_late => 'Pick an earlier date', } ); If form has 'is_html5' flag active it will render <input type="date" ... /> instead of type="text" AUTHOR
FormHandler Contributors - see HTML::FormHandler COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Gerda Shank. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-25 HTML::FormHandler::Field::Date(3pm)

Featured Tech Videos

All times are GMT -4. The time now is 12:49 PM.
Unix & Linux Forums Content Copyright 1993-2019. All Rights Reserved.
Privacy Policy