Sponsored Content
Full Discussion: perl DBI inserting date\time
Top Forums Shell Programming and Scripting perl DBI inserting date\time Post 302349293 by hcclnoodles on Monday 31st of August 2009 04:14:47 PM
Old 08-31-2009
thanks ilikecows, I really thought i could use one of the built in mysql time/date functions... ive used now() before with PHP, maybe DBI in perl doesnt support it

---------- Post updated at 09:14 PM ---------- Previous update was at 07:58 PM ----------

I did it this way in the end (in case its useful to others)

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
my $datetime = printf "%4d-%02d-%02d %02d:%02d:%02d\n",$year+1900,$mon+1,$mday,$hour,$min,$sec;
print $datetime;


10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Inserting Date&Time Stamp In Existing Log File

I am trying to insert a line with a date stamp in a file that is used to monitor activity in one of our directories. By doing this, I want to grep that file each day and go to the last entry for each time a error occurred and pull all errors generated if any exist. If error exists I want that error... (3 Replies)
Discussion started by: shephardfamily
3 Replies

2. Shell Programming and Scripting

PERL DBI module install

We ran into an issue trying to install DBI and DB2 modules for perl for AIX from the link http://www-306.ibm.com/software/data/db2/perl/ We tried to install the DBI module using bash# perl -MCPAN -e 'install DBI' command. However we ended up with the following error. Stop. ... (3 Replies)
Discussion started by: jerardfjay
3 Replies

3. Programming

perl dbi to oracle getting disconnect_all for oracle dbi help

hi i am trying to connect to an oracle database using dbi and i get this :: Driver has not implemented the disconnect_all method. at /opt/perl/lib/site_perl/5.8.0/sun4-solaris/DBI.pm line 575 END failed--call queue aborted. for all i know, the script was working earlier, but has... (1 Reply)
Discussion started by: poggendroff
1 Replies

4. Shell Programming and Scripting

Installing Perl DBI and DBD

Hi, i have some queries on installing the Perl DBI and the DBD Oracle. I know that i have to install the DBI first. I have the source files in a folder in my home directory.The commands to install arecd /home/DBI Perl Makefile.PL make make installI would like to know, after executing these... (4 Replies)
Discussion started by: new2ss
4 Replies

5. Shell Programming and Scripting

connect to MySQL from Perl using DBI

Hi, I want to connect perl with the mysql to select and so on but the connection don't work code #!/usr/bin/perl BEGIN { # PERL MODULES WE WILL BE USING use DBI; $dbh = DBI->connect('DBI:mysql:C:\Program Files\MySQL\MySQL Server 5.0\data\db1','','pass') or die $DBI::errstr;} #... (1 Reply)
Discussion started by: eng_shimaa
1 Replies

6. UNIX for Advanced & Expert Users

Perl's DBI Module on OS X - uninstallable?

i've been struggling with installing the Perl DBI & DBD modules all weekend, and I'm getting close, but no cigar as of yet. When I run the perl script db.pl I get the following mismatch error: Mon Apr 19 09:43:29 EDT 2010 /Library/Perl/DBD-mysql-4.011 -> peterv@MBP17.local<515>$: db.pl | tee... (0 Replies)
Discussion started by: peterv6
0 Replies

7. Shell Programming and Scripting

perl: help with DBI

Hi there, I have a bit of code similar to below (which ive actually got from perldoc, but mine is similar enough) $sth = $dbh->prepare(q{ SELECT region, sales FROM sales_by_region }); $sth->execute; my ($region, $sales); # Bind Perl variables to columns: $rv =... (4 Replies)
Discussion started by: hcclnoodles
4 Replies

8. Shell Programming and Scripting

Date and Time in PERL

Hi, I want to get the current date and time and subtract 1 day to get to the previous day? I see timelocal( ) and (time) etc. How do I code this in PERL to get the previous day? Thanks Nurani (2 Replies)
Discussion started by: nurani
2 Replies

9. Shell Programming and Scripting

Creating a date (without time) in perl

I have a perl script that automatically runs on Mondays. I need to have it create a variable for last Monday's date thru that Sunday's date. example: 04-01-2011 thru 04-08-2011 Its reporting numbers for the previous week beginning with Monday and ending on Sunday. So i dont have to go in... (7 Replies)
Discussion started by: bbraml
7 Replies

10. Shell Programming and Scripting

Perl DBI error

Hi All, I installed DBI module in a non INC location and using it in my script via "use lib". But it throw the below error at the "use DBI" step. Please help Usage: DBI::_install_method(dbi_class, meth_name, file, attribs=Nullsv) at /xx/xxx/xxxxx/xxxxx/oracle/lib/DBI.pm/oracle/lib/DBI.pm line... (2 Replies)
Discussion started by: prasperl
2 Replies
Time::y2038(3pm)					User Contributed Perl Documentation					  Time::y2038(3pm)

Time::y2038 - Versions of Perl's time functions which work beyond 2038 SYNOPSIS
use Time::y2038; print scalar gmtime 2**52; # Sat Dec 6 03:48:16 142715360 DESCRIPTION
On many computers, Perl's time functions will not work past the year 2038. This is a design fault in the underlying C libraries Perl uses. Time::y2038 provides replacements for those functions which will work accurately +/1 142 million years. This only imports the functions into your namespace. To replace it everywhere, see Time::y2038::Everywhere. Replaces the following functions: gmtime() See "gmtime" in perlfunc for details. localtime() See "localtime" in perlfunc for details. timegm() my $time = timegm($sec, $min, $hour, $month_day, $month, $year); The inverse of "gmtime()", takes a date and returns the coorsponding $time (number of seconds since Midnight, January 1st, 1970 GMT). All values are the same as "gmtime()" so $month is 0..11 (January is 0) and the $year is years since 1900 (2008 is 108). # June 4, 1906 03:02:01 GMT my $time = timegm(1, 2, 3, 4, 5, 6); timegm() can take two additional arguments which are always ignored. This lets you feed the results from gmtime() back into timegm() without having to strip the arguments off. The following is always true: timegm(gmtime($time)) == $time; timelocal() my $time = timelocal($sec, $min, $hour, $mday, $month, $year); my $time = timelocal($sec, $min, $hour, $mday, $month, $year, $wday, $yday, $isdst); Like "timegm()", but interprets the date in the current time zone. "timelocal()" will normally figure out if daylight savings time is in effect, but if $isdst is given this will override that check. This is mostly useful to resolve ambiguous times around "fall back" when the hour between 1am and 2am occurs twice. # Sun Nov 4 00:59:59 2007 print timelocal(59, 59, 0, 4, 10, 107); # 1194163199 # Sun Nov 4 01:00:00 2007 DST, one second later print timelocal(0, 0, 1, 4, 10, 107, undef, undef, 1); # 1194163200 # Sun Nov 4 01:00:00 2007 no DST, one hour later print timelocal(0, 0, 1, 4, 10, 107, undef, undef, 0); # 1194166800 $wday and $yday are ignored. They are only there for compatibility with the return value of "localtime()". LIMITATIONS
The safe range of times is +/ 2**52 (about 142 million years). Although the underlying time library can handle times from -2**63 to 2**63-1 (about +/- 292 billion years) Perl uses floating point numbers internally and so accuracy degrates after 2**52. BUGS &; FEEDBACK See http://rt.cpan.org/Dist/Display.html?Queue=Time-y2038 to report and view bugs. If you like the module, please drop the author an email. The latest version of this module can be found at http://y2038.googlecode.com/ and the repository is at http://y2038.googlecode.com/svn/trunk/ in perl/Time-y2038. You have to check out the whole repository because there are symlinks. AUTHOR
Michael G Schwern <schwern@pobox.com> LICENSE &; COPYRIGHT Copyright 2008-2010 Michael G Schwern This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html SEE ALSO
Time::y2038::Everywhere overrides localtime() and gmtime() across the whole program. The y2038 project at http://y2038.googlecode.com/ <http://xkcd.com/376/> perl v5.14.2 2011-11-15 Time::y2038(3pm)

Featured Tech Videos

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