Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:48:16+00:00 2026-06-17T06:48:16+00:00

When I query a data source directly on an SQL server, there is date

  • 0

When I query a data source directly on an SQL server, there is date and time stamp column returning in a format shown below.

2011-05-26 16:19:20
2013-01-10 15:20:35
2008-01-10 14:51:01
2013-01-10 17:40:31
2008-03-26 18:23:20
2010-03-04 16:18:14

However, when I query that same data source in a perl script and write the results to a .txt file, the date format writes as shown below.

Jun 14 2011 10:49AM
Jun 17 2010 04:23PM
Aug 13 2010 08:28AM
Jun 18 2007 08:41AM
Jul 26 2012 07:18PM
Jun 11 2010 11:37AM
Aug 20 2010 09:28AM

SQL Query:

SELECT TOP 100 PERCENT UserNM AS [User ID], MAX(EventDT) AS [Last Login Date]
FROM    dbo.WFEventLog
GROUP BY UserNM
ORDER BY UserNM

Script Section for Writing to File:

open(FILE, ">cleanup.txt") || die "$!\n";

    while( my $hash_ref = $sth->fetchrow_hashref ){

        my $userid = "$hash_ref->{'UserID'}";
        my $logindt = "$hash_ref->{'Last Login Date'}";

            # dump all registered users into .csv file
            print FILE "$userid \t $logindt\n";

    }

close(FILE);

What I am looking for is the exact format from the SQL results to be written to the file. For some reason there is a reformat happening before that is happening that I do not want.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:48:17+00:00Added an answer on June 17, 2026 at 6:48 am

    I’m assuming you want them in identical format. I’d see first if the database will format it for you, but seeing as I don’t know what database you’re dealing with, perl has several modules that are good for this purpose. The granddaddy of them all is Date::Manip. To format your dates in the format as output by the database, you would:

    UnixDate(ParseDate($in), '%Y-%m-%d %H:%M:%S';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application is showing this error below: Data binding directly to a store query
I'm using SQL Server 2008 with Report Builder 2.0 to try and query data
Is there a way that I can create query against a data source (could
I have an excel workbook which needs to query data from an HTTP server.
Is it possible to filter a named query in a reporting services data source
Normally you can add a query as a new data source in Cognos PowerPlay
I query a hierarchical data source like this: repository.LookupValue(IEnumerable<string> ascendants) where ascendants is a
I have a SQL Server and I want to import data from a view
I'm trying to ping my SQL server with a query for information, and then
I have this HTML: <input type=text id=query data-source=whatever> I have some jQuery that changes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.