Sponsored Content
Top Forums Shell Programming and Scripting How to convert DDMMYYYY to DD MONTH YYYY in Unix Post 302222737 by fpmurphy on Thursday 7th of August 2008 12:47:04 PM
Old 08-07-2008
If you are using ksh93
Code:
$ cdate="07082008"
$ printf "%(%d %B %Y)T\n" $cdate
08 July 2008
$

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert filenames with DDMMYYYY to YYYYMMDD

Okay, I have posted on here one other time and received very fast help, so I figured I'd post again. Searched for awhile and couldn't find exactly what I'm looking for. I am attempting to write a script that will search through a given directory, or search through the current directory, and... (10 Replies)
Discussion started by: cbo0485
10 Replies

2. Shell Programming and Scripting

Convert DD-MMM-YYYY to MM-DD-YYYY

I have a file which has 100k+ records like this abc,05-JUN-1974,def,lkj,aaa def,11-SEP-1975,ghj,dis,dea I want to convert ex 05-JUN-1974 to 06/05/1974 Please help me with awk script to convert the whole file into MM-DD-YYYY Thank you! (2 Replies)
Discussion started by: nuthalapati
2 Replies

3. Shell Programming and Scripting

Sed: zero-padding dates (or: convert d/m/yyyy to dd/mm/yyyy)

Hi all I have some pipe-separated data in the form: 5/12/2008 00:00:00|31/1/2009 00:00:00|SOMESTUFF|OTHERSTUFF 12/31/2008 00:00:00|15/1/2009 00:00:00|MORESTUFF|REMAININGSTUFF 1/1/1023 00:00:00|16/5/2047 00:00:00|THEREST|YETMORE I need to zero-pad the single-digit days and months, using... (3 Replies)
Discussion started by: jgrogan
3 Replies

4. Shell Programming and Scripting

convert d/m/yyyy to YYYY-MM-DD

My csv has data like this x,x,3452,2/18/1986,abc x,g,19711,1/24/1986,abc i want to replace date in the following format YYYY-mm-dd how do i convert using awk script ? (8 Replies)
Discussion started by: nuthalapati
8 Replies

5. AIX

Convert unix timestamp to year month day format ?

Hello, How do I convert unix timestamp value to 'normal' date format - to get year month and day values ? Looks like it's easy to do using GNU date (linux systems). But how do I do tthis on AIX ? I don't want to write C program, any ways to do that using unix shells ? thanks (1 Reply)
Discussion started by: vilius
1 Replies

6. Shell Programming and Scripting

Convert From Month Number to Month Name

Hi, I have a script that accepts an input date from the user in yyyy-mm-dd format. I need to get the mm-dd part and convert it to month name. example: 2011-11-15 I want that to become "Nov 15" I don't have the GNU date, I am using an AIX os. Thanks. (1 Reply)
Discussion started by: erin00
1 Replies

7. Shell Programming and Scripting

How to get last 12 month date in YYYY.MM format?

I need the date format in YYYY.MM format and I am able to get current month date as well as previous month date with below command PM=`date +'%Y.%m' -d 'last month'` CM=`date +'%Y.%m' -d 'now'` but I need to get YYYY.MM date format for previous 12 months so could you please help me how I get... (2 Replies)
Discussion started by: Amit Joshi
2 Replies

8. Shell Programming and Scripting

Bash to convert to m-d-yyyy

I am using bash that when run downloads a file a verifies that there is data in it. What I am not able to do is have a user enter a date in any format they wish and have it converted to m-d-yyyy. Thank you :). Bash printf " Welcome to NGS analysis, checking for new files and creating a... (2 Replies)
Discussion started by: cmccabe
2 Replies

9. Shell Programming and Scripting

Convert date in dd mm yyyy format to UNIX timestamp

Hello All, I have a date in DD/MM/YYYY format. I am trying to convert this into unix timestamp. I have tried following: date -d $mydate +%s where mydate = 23/12/2016 00:00:00 I am getting following error: date: extra operand `+%s' Try `date --help' for more information. ... (1 Reply)
Discussion started by: angshuman
1 Replies

10. UNIX for Advanced & Expert Users

How to convert mmm-yy to mm/dd/yyyy format in UNIX ?

How to convert mmm-yy to mm/dd/yyyy format in unix ? example: Jan-99 to 01/01/1999 Jan-00 to 01/01/2000 Jan-25 to 01/01/2025 Dec-99 to 01/12/1999 Dec-00 to 01/12/2000 Dec-25 to 01/12/2025 YY anything between 00-50 should be 2000-2050 YY anything between 51-99 should be 1951-1999 ... (2 Replies)
Discussion started by: gksenthilkumar
2 Replies
Log::Handler::Output::DBI(3pm)				User Contributed Perl Documentation			    Log::Handler::Output::DBI(3pm)

NAME
Log::Handler::Output::DBI - Log messages to a database. SYNOPSIS
use Log::Handler::Output::DBI; my $db = Log::Handler::Output::DBI->new( # database source database => "database", driver => "mysql", host => "127.0.0.1", port => 3306, # or with "dbname" instead of "database" dbname => "database", driver => "Pg", host => "127.0.0.1", port => 5432, # or with data_source data_source => "dbi:mysql:database=database;host=127.0.0.1;port=3306", # Username and password user => "user", password => "password", # debugging debug => 1, # table, columns and values (as string) table => "messages", columns => "level ctime cdate pid hostname progname message", values => "%level %time %date %pid %hostname %progname %message", # table, columns and values (as array reference) table => "messages", columns => [ qw/level ctime cdate pid hostname progname message/ ], values => [ qw/%level %time %date %pid %hostname %progname %message/ ], # table, columns and values (your own statement) statement => "insert into messages (level,ctime,cdate,pid,hostname,progname,message) values (?,?,?,?,?,?,?)", values => [ qw/%level %time %date %pid %hostname %progname %message/ ], # if you like persistent connections and want to re-connect persistent => 1, ); my %message = ( level => "ERROR", time => "10:12:13", date => "1999-12-12", pid => $$, hostname => "localhost", progname => $0, message => "an error here" ); $db->log(\%message); DESCRIPTION
With this output you can insert messages into a database table. METHODS
new() Call "new()" to create a new Log::Handler::Output::DBI object. The following options are possible: data_source Set the dsn (data source name). You can use this parameter instead of "database", "driver", "host" and "port". database or dbname Pass the database name. driver Pass the database driver. host Pass the hostname where the database is running. port Pass the port where the database is listened. user Pass the database user for the connect. password Pass the users password. table and columns With this options you can pass the table name for the insert and the columns. You can pass the columns as string or as array. Example: # the table name table => "messages", # columns as string columns => "level, ctime, cdate, pid, hostname, progname, message", # columns as array columns => [ qw/level ctime cdate pid hostname progname message/ ], The statement would created as follows insert into message (level, ctime, cdate, pid, hostname, progname, mtime, message) values (?,?,?,?,?,?,?) statement With this option you can pass your own statement if you don't want to you the options "table" and "columns". statement => "insert into message (level, ctime, cdate, pid, hostname, progname, mtime, message)" ." values (?,?,?,?,?,?,?)" values With this option you have to set the values for the insert. values => "%level, %time, %date, %pid, %hostname, %progname, %message", # or values => [ qw/%level %time %date %pid %hostname %progname %message/ ], The placeholders are identical with the pattern names that you have to pass with the option "message_pattern" from Log::Handler. %L level %T time %D date %P pid %H hostname %N newline %C caller %p package %f filename %l line %s subroutine %S progname %r runtime %t mtime %m message Take a look to the documentation of Log::Handler for all possible patterns. persistent With this option you can enable or disable a persistent database connection and re-connect if the connection was lost. This option is set to 1 on default. dbi_params This option is useful if you want to pass arguments to DBI. The default is set to { PrintError => 0, AutoCommit => 1 } "PrintError" is deactivated because this would print error messages as warnings to STDERR. You can pass your own arguments - and overwrite it - with dbi_params => { PrintError => 1, AutoCommit => 0 } debug With this option it's possible to enable debugging. The information can be intercepted with $SIG{__WARN__}. log() Log a message to the database. my $db = Log::Handler::Output::DBI->new( database => "database", driver => "mysql", user => "user", password => "password", host => "127.0.0.1", port => 3306, table => "messages", columns => [ qw/level ctime message/ ], values => [ qw/%level %time %message/ ], persistent => 1, ); $db->log( message => "your message", level => "INFO", time => "2008-10-10 10:12:23", ); Or you can connect to the database yourself. You should notice that if the database connection lost then the logger can't re-connect to the database and would return an error. Use "dbi_handle" at your own risk. my $dbh = DBI->connect(...); my $db = Log::Handler::Output::DBI->new( dbi_handle => $dbh, table => "messages", columns => [ qw/level ctime message/ ], values => [ qw/%level %time %message/ ], ); connect() Connect to the database. disconnect() Disconnect from the database. validate() Validate a configuration. reload() Reload with a new configuration. errstr() This function returns the last error message. PREREQUISITES
Carp Params::Validate DBI your DBI driver you want to use EXPORTS
No exports. REPORT BUGS
Please report all bugs to <jschulz.cpan(at)bloonix.de>. If you send me a mail then add Log::Handler into the subject. AUTHOR
Jonny Schulz <jschulz.cpan(at)bloonix.de>. COPYRIGHT
Copyright (C) 2007-2009 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-11-21 Log::Handler::Output::DBI(3pm)
All times are GMT -4. The time now is 02:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy