To solve a similar problem, I wrote code to allow an environment variable to override the current date and time. The Perl code would use the real current time if the environment variable was unset, or would use the one from the environment if it was set. This did require some changes to the Perl code, but worked pretty well, and I can test how the code would work on different dates by changing the environment variable.

Another possibility worth investigating is abusing time zones. Some systems will let you set a timezone offset of something like "72 hours" which will make the date appear forward or backwared a 3 days. If your database has some notion of per-connection timezones, a trick like that could work.


In reply to Re: Testing and database date functions by sgifford
in thread Testing and database date functions by relax99

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.