Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Date Format and changing it

Posted on 2013-10-23
4
Medium Priority
?
249 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
[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
  • 2
4 Comments
 
LVL 58

Assisted Solution

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

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

Accepted Solution

by:
Chris Stanyon earned 1000 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 44

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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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 a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

618 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