Solved

Date Format and changing it

Posted on 2013-10-23
4
216 Views
Last Modified: 2013-10-23
If I run A query to find a field that contains a day of the week (%d)
and the return == 01 or 02 how do I change that so it is the date Format for day (%j)
so that there is no leading 0.

for eaxample the code to change it from 01 to 1
02 to 2
03 to 3
however 13 would still be 13 and so forth.
0
Comment
Question by:rgranlund
  • 2
4 Comments
 
LVL 58

Assisted Solution

by:Gary
Gary earned 250 total points
ID: 39595748
You could use float e.g.

$p="01";
echo (float)$p;
0
 
LVL 42

Accepted Solution

by:
Chris Stanyon earned 250 total points
ID: 39595782
Personally, I'd use int:

$p="01";
echo (int)$p;

;)
0
 
LVL 7

Author Comment

by:rgranlund
ID: 39595861
What is the difference between float and int?
0
 
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39595869
float is for floating point numbers (numbers with a decimal point) and int is for integers - whole numbers only.

Gary was on the right track and deserves the points but as your day is only ever going to be a number between 1 and 31 it makes sense to convert it to an integer!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now