Solved

Date Format and changing it

Posted on 2013-10-23
4
217 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 43

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 43

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

919 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

16 Experts available now in Live!

Get 1:1 Help Now