Solved

Date Format Win32::ODBC Ms Accesss

Posted on 2003-10-22
7
336 Views
Last Modified: 2010-03-04
Hi experts

this should be very easy :) I am using Win32::ODBC to connect to an access DB I am having problems getting the right format for date I keep getting it in this format 2003-09-21 00:00:00 and I want it to be shown as this 09-21-2003 without changing anything in MS Accsses... Cheers

Thank you in advance


use Win32::ODBC;
#####$ODBCDate = sprintf("{d '%d-%d-%d'}", , $day,$mon,$year);
my $db = new Win32::ODBC("DSN=blah");
my $statement= "SELECT *FROM blahblah";
if($db->Sql($statement))
      {
      my $errortext=$db->Error();
      # error-handling code here
      $db->Close();
      exit
      }
while ($db->FetchRow())
      {
      %Records = $db->DataHash();
      $tablebody .= "<tr>";
      $tablebody .= "<td nowrap>&nbsp;".$Records{"Date"}."</td>";
      $tablebody .= "<tr>"
      }
$db->Close();

#result screen
print <<EOF ;
Content-type: text/html

<html>
<head>

</head>
<body bgcolor="#FFFFCC" link="#660000" vlink="#660000" text="#000066">
<Center>
<p><font size="4" color="#000066">Blah</p>
<table border="1" bordercolor="#000066">
<tr>
  <th>Date</th>
</tr>
  $tablebody
</table>
</body>
</html>
EOF

0
Comment
Question by:baz_can_fix_it
  • 4
  • 2
7 Comments
 
LVL 5

Accepted Solution

by:
fantasy1001 earned 20 total points
ID: 9605847
Put simple:
you want to change 2003-09-21 00:00:00 to 09-21-2003

$temp = split / /, $Records{"Date"};
my($year, $month, $day) = split /-/, $temp;

$temp = join "-", $month, $day, $year;

Thanks & cheers
0
 
LVL 1

Author Comment

by:baz_can_fix_it
ID: 9611106
Hi fantasy1001

That gives me now  --2 as date... any ideas?  here is what i did

while ($db->FetchRow())
      {
      %Records = $db->DataHash();
      $temp = split / /, $Records{"Date"};
      my($year, $month, $day) = split /-/, $temp;
      $temp = join "-", $month, $day, $year;

      $tablebody .= "<tr>";
      $tablebody .= "<td nowrap>&nbsp;$temp</td>";

Cheers
0
 
LVL 1

Author Comment

by:baz_can_fix_it
ID: 9611420
Hi fantasy1001

Don't worry thanx for trying I have fix the problem my self...Here is how...Cheers

my($year,$month,$day ) = split ('[/.-]', $Records{"Date"});
my($d,$hr,$min,$sec) = split ('[/ :/]', $day);
$tablebody .= "<td nowrap>&nbsp;$d/$month/$year</td>";
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 20

Expert Comment

by:jmcg
ID: 9611664
Fantasy should have said:

   my ( $temp) = split / /, $Records{Date};

by leaving out the parens, split returns a count rather than the results of the split.

==========

If you don't like what he showed you and you found your own solution, you are within your rights to request a points refund in Community Support (now it's that CS tab on the far right of that menu bar that appears in the "new" look for Experts Exchange).
0
 
LVL 1

Author Comment

by:baz_can_fix_it
ID: 9611710
Hi jmcg

Thanx for that...How do i split the points 10 for you and 10 for fantsy1001...there use to be a split option like assisted answer...this new look is confusing me :)
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9611744
I'm still reserving judgement on the new look. There have been a few improvements since it was first introduced.

If you don't have a split points button, it may be because you are not allowed to split at 20-point question. The powers-that-be do not want to see less than 20 points awarded, which limits how fine your splits can be.

If you have limited points, ask for a refund. You'll be able to ask another question with them. If you feel like you have plenty of points, go ahead and accept Fantasy's answer. He was first on the scene and gave you something that was real close to working.

0
 
LVL 1

Author Comment

by:baz_can_fix_it
ID: 9611783
Thank you both...

Ye i must admit the look is getting better and better every day...sometimes the "your status" table would go a meter to the right side :) lol....But you all doing an excellent job and this is the best place on the net...

Cheers

0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question