Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Assistance needed with code (Dates)

Posted on 2007-12-03
23
Medium Priority
?
813 Views
Last Modified: 2010-04-21
Hi all,

I am reading a list of headers from online images and it is reading and the formats show right BUT
when a Match is found it's ignoring it.

Basically: if NewOnlineImg = StrToDate(SetDate) then
                .....
     
               is not working!

               I've changed things around a million times so you are my last resort!
               Please help!!!

              Thanks
   
              ST3VO



procedure TForm1.Button4Click(Sender: TObject);
var i: integer;
    OnlineImg, SetDate, VRShopImgPath: String;
    LocalDate, NewOnlineImg: TDate;
begin
 
 
  for i := 0 to ListBox1.Items.Count - 1 do //Loop the listbox items
    begin
 
    try
 
      Idhttp1.Head(Listbox1.Items[i]); //The Images on the listbox
      OnlineImg:=(Idhttp1.Response.RawHeaders.Values['Last-Modified']); //Get the Last Modified Stamp
      OnlineImg:=AnsiLeftStr(OnlineImg, 16); //Trim it to show as ddd, dd MMM yyyy
      ListBox4.Items.add(OnlineImg);
 
 
      SetDate:=FormatDateTime('ddd, dd MMM yyyy', DateTimePicker1.Date);
      ListBox3.Items.Add(SetDate);
 
      NewOnlineImg:=StrToDate(OnlineImg);
      ListBox4.Items.Add(DateToStr(NewOnlineImg));
 
 
      if NewOnlineImg = StrToDate(SetDate) then
        begin
      ShowMessage('Match Found');
        //listbox2.Items.Add(Listbox1.Items[i]); // Clear it not new
       // ListBox3.Items.add(NewAutoExposureImg+ ' ' +NewPath);
        //Edit1.Text:=IntToStr(i);
       end;
 
    Except
 
      //continue;
    end;
     Application.ProcessMessages;
end;
 
end;

Open in new window

0
Comment
Question by:ST3VO
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 5
  • 4
  • +1
23 Comments
 
LVL 25

Expert Comment

by:imitchie
ID: 20394925
before 26:       if NewOnlineImg = StrToDate(SetDate) then
add (25) : ShowMessage(FormatDateTime('d/m/yy', NewOnlineImg) + ' = ' +
FormatDateTime('d/m/yy', StrToDate(SetDate)));

and check the output. I'm guessing it has to do with the format of the 'Last-Modified' string
0
 

Author Comment

by:ST3VO
ID: 20394948
Tried it and no messages appeared at all.  And there are matches! :o/

0
 
LVL 25

Expert Comment

by:imitchie
ID: 20394957
     NewOnlineImg:=StrToDate(OnlineImg);
      ListBox4.Items.Add(DateToStr(NewOnlineImg));
 
      if NewOnlineImg = StrToDate(SetDate) then
        begin
      ShowMessage('Match Found');

change the section above, to
      NewOnlineImg:=StrToDate(OnlineImg);
      ListBox4.Items.Add(DateToStr(NewOnlineImg));
 
  ShowMessage(FormatDateTime('d/m/yy', NewOnlineImg) + ' = ' +
FormatDateTime('d/m/yy', StrToDate(SetDate)));
 
      if NewOnlineImg = StrToDate(SetDate) then
        begin
      ShowMessage('Match Found');

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:ST3VO
ID: 20394969
No Messages shown at all :o/
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20394989
which means you have an error WAY before that point (of testing = ). try/except is hiding the error. you should turn on debugging mode and find out where it is breaking
0
 

Author Comment

by:ST3VO
ID: 20395013
I don't get any errors...

Here's the unit and DFM so you can see for yourself!

Hope this helps!!!



////The Unit
 
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdHTTP, StrUtils, Mask, rxToolEdit, ComCtrls, COMMCTRL;
 
type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    Button2: TButton;
    IdHTTP1: TIdHTTP;
    Edit1: TEdit;
    ListBox2: TListBox;
    Button4: TButton;
    ListBox3: TListBox;
    ListBox4: TListBox;
    DateTimePicker1: TDateTimePicker;
    procedure ListBox2DblClick(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure ListBox1DblClick(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    FDestinationFolder:String;
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
Uses WinInet;
 
function ExtractURLFileName(aPath : string) : string;
var I : integer;
begin
   I:=length(aPath);
   while (I>0) and (aPath[I] <> '/') do dec(I);
   result:=Copy(aPath,I+1,length(aPath)-I);
end;
 
 
 
function GetInetFile (const fileURL, FileName: String): boolean;
const
  BufferSize = 1024;
var
  hSession, hURL: HInternet;
  Buffer: array[1..BufferSize] of Byte;
  BufferLen: DWORD;
  f: File;
  sAppName: string;
begin
 result := false;
 sAppName := ExtractFileName(Application.ExeName) ;
 hSession := InternetOpen(PChar(sAppName), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0) ;
 try
  hURL := InternetOpenURL(hSession, PChar(fileURL), nil, 0, 0, 0) ;
  try
   AssignFile(f, FileName) ;
   Rewrite(f,1) ;
   repeat
    InternetReadFile(hURL, @Buffer, SizeOf(Buffer), BufferLen) ;
    BlockWrite(f, Buffer, BufferLen)
   until BufferLen = 0;
   CloseFile(f) ;
   result := True;
  finally
   InternetCloseHandle(hURL)
  end
 finally
  InternetCloseHandle(hSession)
 end
end;
 
 
function GetFileName(Path: String): String;
var TmpName:String;
    StartPos:Integer;
begin
   try
      StartPos:=length(Path);
      While StartPos>0 do
      begin
        if path[StartPos]='/' then Break;
        dec(StartPos);
      end;
      Result:=copy(Path,StartPos+1,Length(path));
   except
     Result := #0;
   end;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
var i:Integer;
begin
   Button1.Enabled:=False ;
   Screen.Cursor:=crHourGlass;
   for i:=0 to ListBox2.Items.Count-1 do
   begin
    if not GetInetFile(ListBox2.Items.Strings[i],
               FDestinationFolder+GetFileName(ListBox2.Items.Strings[i])) then
       ShowMessage('Error while downloading ' + ListBox2.Items.Strings[i]);
   end;
   Button1.Enabled:=True;
   Screen.Cursor:=crDefault;
end;
 
procedure TForm1.Button2Click(Sender: TObject);
begin
  Listbox1.Clear;
  ListBox1.Items.LoadFromFile('URLList2.txt');
end;
 
procedure TForm1.Button3Click(Sender: TObject);
 
 
var ImageStampDate, DataTimeNow : String;
i: integer;
begin
 
  for i := 0 to ListBox1.Items.Count - 1 do //Loop the listbox items
    begin
      //if i > 0 then
      // Begin
 
    try
      sleep(2000);
      Idhttp1.Head(Listbox1.Items[i]); //Assign the current selection count
      ImageStampDate:=(Idhttp1.Response.RawHeaders.Values['Last-Modified']); //Get Last Modified from image online
      //StrToDate(ImageStampDate, 'ddd, d mmm yyyy');
      DataTimeNow:=FormatDateTime('ddd, d mmm yyyy hh:mm:ss "GMT"', now); //Get Now FormatDate
      ImageStampDate:=AnsiLeftStr(ImageStampDate, 16); //Only leave the Date
      DataTimeNow:=AnsiLeftStr(DataTimeNow, 16);  //Only leave the Date
      if DataTimeNow <> ImageStampDate then
        begin
        listbox2.Items.Add(Listbox1.Items[i]); // Clear it not new
        listbox1.Items.Delete(i);
        Edit1.Text:=IntToStr(i);
       end;
 
    Except
      begin
        listbox1.Items.Delete(i); // Clear it not new
        Edit1.Text:=IntToStr(i);
      end;
      //continue;
    end;
     Application.ProcessMessages;
end;
 
end;
 
 
 
 
 
 
 
 
 
procedure TForm1.Button4Click(Sender: TObject);
var i: integer;
    OnlineImg, SetDate, VRShopImgPath: String;
    LocalDate, NewOnlineImg: TDate;
begin
 
 
  for i := 0 to ListBox1.Items.Count - 1 do //Loop the listbox items
    begin
 
    try
 
      Idhttp1.Head(Listbox1.Items[i]); //The Images on the listbox
      OnlineImg:=(Idhttp1.Response.RawHeaders.Values['Last-Modified']); //Get the Last Modified Stamp
      OnlineImg:=AnsiLeftStr(OnlineImg, 16); //Trim it to show as ddd, dd MMM yyyy
      ListBox4.Items.add(OnlineImg);
 
 
      SetDate:=FormatDateTime('ddd, dd MMM yyyy', DateTimePicker1.Date);
      ListBox3.Items.Add(SetDate);
 
      NewOnlineImg:=StrToDate(OnlineImg);
      ListBox4.Items.Add(DateToStr(NewOnlineImg));
 
 
      if NewOnlineImg = StrToDate(SetDate) then
        begin
      //ShowMessage('Match Found');
      ShowMessage(FormatDateTime('d/m/yy', NewOnlineImg) + ' = ' +
           FormatDateTime('d/m/yy', StrToDate(SetDate)));
        //listbox2.Items.Add(Listbox1.Items[i]); // Clear it not new
       // ListBox3.Items.add(NewAutoExposureImg+ ' ' +NewPath);
        //Edit1.Text:=IntToStr(i);
       end;
 
    Except
 
      //continue;
    end;
     Application.ProcessMessages;
end;
 
end;
 
procedure TForm1.FormCreate(Sender: TObject);
begin
  FDestinationFolder:= ExtractFileDir(ParamStr(0));
  if FDestinationFolder[Length(FDestinationFolder)]<>'\' then
     FDestinationFolder:=FDestinationFolder+'\';
  FDestinationFolder:=FDestinationFolder+'Files\';
 
  if not DirectoryExists(FDestinationFolder) then
    CreateDir(FDestinationFolder);
end;
 
procedure TForm1.ListBox1DblClick(Sender: TObject);
var s: string;
begin
 
ShowMessage(Listbox1.Items[ListBox1.ItemIndex]);
  Idhttp1.Head(Listbox1.Items[ListBox1.ItemIndex]); //Assign the current selection count
   Showmessage(Idhttp1.Response.RawHeaders.Values['Last-Modified']);
end;
 
procedure TForm1.ListBox2DblClick(Sender: TObject);
begin
ShowMessage(Listbox2.Items[ListBox2.ItemIndex]);
  Idhttp1.Head(Listbox2.Items[ListBox2.ItemIndex]); //Assign the current selection count
   Showmessage(Idhttp1.Response.RawHeaders.Values['Last-Modified']);
end;
 
end.
 
 
////The DFM
object Form1: TForm1
  Left = 135
  Top = 173
  Caption = 'Form1'
  ClientHeight = 583
  ClientWidth = 851
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object ListBox1: TListBox
    Left = 8
    Top = 8
    Width = 265
    Height = 553
    ItemHeight = 13
    Items.Strings = (
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10120/AETV677' +
        '41770_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10120/AETV788' +
        '79418_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10120/AETV879' +
        '99924_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10120/AETV902' +
        '19618_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10120/AETV916' +
        '90881_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10120/AETV952' +
        '44787_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10120/AETV985' +
        '75806_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV147' +
        '15833_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV163' +
        '95440_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV170' +
        '12568_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV229' +
        '61767_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV304' +
        '45530_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV464' +
        '84350_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV477' +
        '08321_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV492' +
        '75484_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV525' +
        '12354_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV558' +
        '35343_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV603' +
        '05166_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV622' +
        '07174_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV681' +
        '18793_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV704' +
        '81607_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV705' +
        '47077_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV719' +
        '32075_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV731' +
        '38048_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV816' +
        '51924_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV817' +
        '90523_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV817' +
        '92210_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV834' +
        '68679_1b.jpg'
      
        'http://imageserver.autoexposure.co.uk/autoedit/AETA10185/AETV847' +
        '54068_1b.jpg')
    TabOrder = 0
    OnDblClick = ListBox1DblClick
  end
  object Button1: TButton
    Left = 768
    Top = 550
    Width = 75
    Height = 25
    Caption = 'Download'
    TabOrder = 1
    OnClick = Button1Click
  end
  object Button2: TButton
    Left = 824
    Top = 488
    Width = 19
    Height = 25
    Caption = 'Load'
    TabOrder = 2
    OnClick = Button2Click
  end
  object Edit1: TEdit
    Left = 752
    Top = 88
    Width = 73
    Height = 21
    TabOrder = 3
    Text = '0'
  end
  object ListBox2: TListBox
    Left = 279
    Top = 8
    Width = 274
    Height = 553
    ItemHeight = 13
    TabOrder = 4
    OnDblClick = ListBox2DblClick
  end
  object Button4: TButton
    Left = 768
    Top = 519
    Width = 75
    Height = 25
    Caption = 'Process'
    TabOrder = 5
    OnClick = Button4Click
  end
  object ListBox3: TListBox
    Left = 559
    Top = 127
    Width = 284
    Height = 154
    ItemHeight = 13
    TabOrder = 6
    OnDblClick = ListBox2DblClick
  end
  object ListBox4: TListBox
    Left = 559
    Top = 287
    Width = 284
    Height = 186
    ItemHeight = 13
    TabOrder = 7
    OnDblClick = ListBox2DblClick
  end
  object DateTimePicker1: TDateTimePicker
    Left = 559
    Top = 61
    Width = 266
    Height = 21
    Date = 39419.439478796300000000
    Format = 'ddd, dd MMM yyyy'
    Time = 39419.439478796300000000
    DateFormat = dfLong
    TabOrder = 8
  end
  object IdHTTP1: TIdHTTP
    AllowCookies = True
    ProxyParams.BasicAuthentication = False
    ProxyParams.ProxyPort = 0
    Request.ContentLength = -1
    Request.Accept = 'text/html, */*'
    Request.BasicAuthentication = False
    Request.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)'
    HTTPOptions = [hoForceEncodeParams]
    Left = 776
    Top = 32
  end
end

Open in new window

0
 

Author Comment

by:ST3VO
ID: 20395095
Found anything?
0
 

Author Comment

by:ST3VO
ID: 20395280
Anyone please???
0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 20395337
hmm...

Some things you can try:

1) TDateTime is actually just a number for the amount of days that have passed since X (usually 31/12/1899 or something), with fractions of numbers to represent the hours minutes and seconds. Therefore if you have two dates that differ by even 1 second, they will not match.
So trim your TDateTimes to isolate the date only!
Add DateUtils to your unit's uses clause, and use DateOf.
Syntax:
DateOf(const AValue: TDateTime): TDateTime;
Example:
if DateOf(NewOnlineImg) = DateOf(StrToDate(SetDate)) then

2) Instead of saying '=', try using comparedate
Add Dateutils to the uses clause of your unit.
Syntax:
function CompareDate(const A: TDateTime; const B: TDateTime): TValueRelationship;
Example:
if CompareDate(NewOnlineImg, StrToDate(SetDate)) = 0 then
OR
if CompareDate(DateOf(NewOnlineImg), DateOf(StrToDate(SetDate))) = 0 then

3) Diagnostics. Get the system to tell you the dates it is trying to compare
Examples:
Showmessage(IntToStr(CompareDate(NewOnlineImg, StrToDate(SetDate))));
OR
Showmessage(DateToString(NewOnlineImg));
Showmessage(DateToString(StrToDate(SetDate)))
OR
Showmessage(DateTimeToString(NewOnlineImg));
Showmessage(DateTimeToString(StrToDate(SetDate)))
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20395340
Why do you insist on moving my debug code??

      ShowMessage(FormatDateTime('d/m/yy', NewOnlineImg) + ' = ' +
           FormatDateTime('d/m/yy', StrToDate(SetDate)));      if NewOnlineImg = StrToDate(SetDate) then
        begin
      //ShowMessage('Match Found');


Debug message comes BEFORE the test to validate the test.  I gotta go off anyway, so good luck for many hours to come.
0
 

Author Comment

by:ST3VO
ID: 20395450
Right....Some more info I found:

The Original image result I get is: ddd, dd MMM yyyy hh:mm:ss GMT

So I used this to take off the excess and match the DateTimePicker format which is:  ddd, dd MMM yyyy

OnlineImg:=AnsiLeftStr(OnlineImg, 16); //Trim it to show as ddd, dd MMM yyyy

This gives me an error message " 'Thu, 30 Nov 2007' is not a valid date

This is returned by the CompareDate Function.

Any ideas??



0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 20395504
Well you need to get it to TDateTime, you can do that using StrToDateTime. Look up in your Delphi help file StrToDateTime - there are two ways it can be used, the second way allows you to specify TFormatSettings, which will allow you to convert your string to a TDateTime.

Or alternatively, if you managed to convert from ddd, dd MMM yyyy hh:mm:ss GMT to a TDateTime before, then do that, just trim it using DateOf() which will remove the time part (hh:mm:ss GMT) and just keep the date (technically it sets the time to '0' which is midnight).
0
 

Author Comment

by:ST3VO
ID: 20395548
Is this not allowed?

Idhttp1.Head(Listbox1.Items[i]); //The Images on the listbox
      OnlineImg:=(Idhttp1.Response.RawHeaders.Values['Last-Modified']); //Get the Last Modified Stamp
      OnlineImg:=AnsiLeftStr(StrToDateTime(OnlineImg, 16)); //Trim it to show as ddd, dd MMM yyyy

Won't compile :o/
0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 20395573
What is this? StrToDateTime(OnlineImg, 16) ???
The first parameter is a string ("OnlineImg") the second parameter can only be TFormatSettings -- and "16" is not a TFormatSetting.
You can try this:
OnlineImg := StrToDateTime(AnsiLeftSr(OnlineImg, 16));
0
 

Author Comment

by:ST3VO
ID: 20395579
Trying this but get message invalid date too...Grrr :o(

Idhttp1.Head(Listbox1.Items[i]); //The Images on the listbox
      OnlineImg:=(Idhttp1.Response.RawHeaders.Values['Last-Modified']); //Get the Last Modified Stamp
      OnlineImg:=AnsiLeftStr(OnlineImg, 16); //Trim it to show as ddd, dd MMM yyyy
      NewOnlineImg:=StrToDateTime(OnlineImg);
      Showmessage(DateToStr(NewOnlineImg)); //Error Not a valid Date
0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 20395588
Ooh... problem with my exampleabove. What type of variable is OnlineImg?
I think you mean: NewOnlineImg := StrToDateTime(AnsiLeftSr(OnlineImg, 16));
0
 

Author Comment

by:ST3VO
ID: 20395690
Hmmm:

[Pascal Error] Unit1.pas(187): E2003 Undeclared identifier: 'AnsiLeftSr'

Why is this sooo hard ? :o/
0
 

Author Comment

by:ST3VO
ID: 20396046
Can anyone help pleaseee????

0
 

Author Comment

by:ST3VO
ID: 20396097
In basic terms all I need to do is:

Var OnlineImg: String

A: OnlineImg:=(Idhttp1.Response.RawHeaders.Values['Last-Modified']); //Returns a String

Convert that string to Format : ddd, dd MMM yyyy

Then I have a TDateTimePicker - Format must also be: ddd, dd MMM yyyy // which it is

Then If OnlineImg = DateTimePicker.date then
  showmessage('Match Found');

Hope this is eaiser to understand!

0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 20396207
I spent quite a while searching for ways to convert your string Thursday, 30 Nov 2007
into TDateTime format or even TDate format.
I came close, but not close enough to get it right.
I obviously did tests without the 'Thursday' because you can lose that, and only use '30 Nov 2007'.
This uses the format d MMM yyyy and it refused to convert it using StrtoDateTime(String, TFormatSettings).

I am going to bed, and will try look some more tomorrow.

One other alternative is to use EncodeDate (see DateUtils.EncodeDate).
For this you will need to isolate your string into its little components:
Day string
Month String
Year String
then do something like NewOnlineImg := EncodeDate(strtoint(YearString), strtoint(MonthString), strtoint(DayString))
(check the helpfile for proper syntax).
And then you will have a problem with your Month String, it needs an integer. So you have to convert Nov to 11. I do believe there is a DateUtils function that can do that for you too.

You can use the EncodeDate method as a last resort.. There has to be a way to use StrToDateTime with your date format, i.e. ddd, d MMM yyyy)

Good luck!
0
 

Author Comment

by:ST3VO
ID: 20396297
Thanks! I'll keep on trying!!! :o)
0
 
LVL 5

Accepted Solution

by:
Steven-Fernandez earned 2000 total points
ID: 20397593
Why not try to convert it to a short format date?

Check the code below and let me know if you need any more help.


function TForm1.LongDateToShort(sDate: String): String;
var
  i: Integer;
  sl: TStringList;
  sMon: string;
begin
  try
    // split out the long string (assume always same format)
    sl := TStringList.Create;
    sl.Delimiter := ' ';
    sl.DelimitedText := sDate;
    // loop through locale short month names and find index
    for i := 1 to 12 do
      if Uppercase(ShortMonthNames[i]) = Uppercase(sl.Strings[2]) then Break;
    // correct format
    sMon := IntToStr(i);
    if Length(sMon) = 1 then
      sMon := '0' + sMon;
    // rebuild date string
    Result := Trim( sl.Strings[1] + '/' + sMon + '/' + sl.Strings[3] );
  finally
    FreeAndNil(sl)
  end;
end;
 
Then:
 
if idhttp1.Response.RawHeaders.IndexOfName('Last-Modified') > -1 then
         OnlineImg:=(Idhttp1.Response.RawHeaders.Values['Last-Modified']);
         NewOnlineImg:= LongDateToShort(OnlineImg);
         SetDate:=(DateToStr(DateTimePicker1.Date));
 
         ...
 
if NewOnlineImg = (SetDate) then
        begin
      ShowMessage('Match Found');
       
      ...

Open in new window

0
 

Author Closing Comment

by:ST3VO
ID: 31412297
Woohhoo...it's works perfect!!!

Thanks a million!!!

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

730 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