I have a site I'm doing where the owners wants to have a line in each bio: "Bill has been with us xx years". I don't want to have to go in at everyone's anniversary and change it. I know enough JS to break things, but I'm an advanced expert at copy and paste!! :-)
The client has given us the start month & year and we, obviously, know the current month and year. So I just need the code to do the calculation. I've looked at a whole mass of pages which seen to details this pretty well (if you know a bit of JS), but they all use a full date - MMDDYYYY - rather than just MMYYYY.
Related
I'm looking to create a spreadsheet to get a grasp of what my personal finances are saying. Part of this obviously involves putting in income from my job. While I know my shifts in advance so I know how much I will be earning on any given day, I won't actually get the money until the end of the month.
I've created a cell called 'bank balance' based on my current savings, but obviously I don't want to have to physically update this every time I get paid so I'd like to just be able to give Sheets a date where it can update that cell itself based on my payday.
For example:
I start off with £100 in my bank account on January 15th. I know I'm going to get paid £400 on January 28th (last working day of the month). I don't want to input that on Jan 15th as that wouldn't be an accurate reflection of my finances. So I input something that tells sheets to add that £400 on to the bank balance cell on Jan 28th for me.
[The example sheet on January 15th]
[The example sheet on payday January 28th after automatically adding on the £400 to the bank balance]
I've currently got a separate cell for 'work income' that I want to apply this function to (I.E. so that I can tell the sheet to add the total 'work income' to 'bank balance' on payday) but I'm not sure where to go from here.
I've got similar issues with subscriptions leaving my account on various days of the month but the income is my higher priority.
Any help with this would be greatly appreciated
I'm pretty new in Tableau. I have looked at the forum already and the answered suggested. But I'm not quite sure it match my question.
I have a bunch of records. This is about registration for a sport lesson depending on time. All of them have a start date and and some of them a finish date. The other never finish (They continue until date T with T = now).
My goal is to compare only the first 6 months of all my records, I think there are 50 of them, like the evolution during this period of time. So, for some the start date would be in January 2009, for some other, it would be in May 2016, etc.
As field provided, I have the start date and the number of person that have subscribed those lesson through time.
So, do you if there is any to achieve this goal? Is there enough detail for you to understand what I am saying ?
Thx to you guys !!
EDIT
You can find enclosed a screenshot of the result that I already have.
number of registration for all lesson through time
I'm not sure to be clear, what I try to do is to compare the first 6 months only of each courses. So the evolution of the first 6 months of this course compare to the evolution of the first 6 months of this other course and so on :)
If I understand your question correctly you are wanting to show only the first six months of your data but you want this by each category.
I am assumuming that by definition this means 6 months from the first record in your data for each category.
In order to achieve this I would create a true/false flag using a level of detail expression. As you are new to tableau I would suggest you do some reading on this but basically you can force a calculation to be at a certain level of the data rather than at the row level. You use this to find the minimum date in the table and then use a date diff to return true if the actual date field is within 6 months of this.
Create a calculated field as follows:
[date] <= DATEADD('month', 6, { FIXED [category] :min([date])})
Then drag this onto your filters pane and select "TRUE". This should give you only the first six months of records for each category.
Let me know if you need anything else.
How to protect only Month and Year of a date in Powerbuilder so user can only edit day of the date?
As comments suggest, this reads more like a user requirement than a technical question (e.g. lack of mention of what type of control is involved), but if this were my requirement, I'd try one of these (user exercise to figure out which ones would actually work; it's not my requirement grin).
EditChanged: I'd put a date EditMask on a DataWindow (remember external DataWindows; it's a common misconception to think that controls on DataWindows have to be tied to a database column), and code the EditChanged to revert the year and month back to their set values if they've been changed. (I'd consider this pretty aggravating for the user, but it's possible)
Day field: Make the year and month StaticText, and make the day only an editable field. Edit, EditMask or EditMask with spin control would be appropriate for this (spin gives you control over the range with minimal scripting).
Custom control: Grab the source code for a dropdown calendar (PFC comes to mind), and customize it to disable the navigation between years and months.
Good luck,
Terry
Upon logging into their accounts, each user has their login date and time stored to the database. What I was looking to do however is figure out the amount of days (or preferably convert into months if greater than a month) so that if a user views their profile they can see how active the band are. Also, this could benefit me in terms of keeping active profiles top of the agenda for content on the site so that it doesn't become stale from inactive users content filling up main page content.
I'm using ColdFusion so i'd be looking for a way to find for example how many days ago #lastLogin# was from #now()#. So say if the date of the last login was 23/04/2013 and todays date is 29/04/2013 it would read "Last Active, 1 day ago." However if the last login was 23/03/2013, it would read "Last Active, 1 month ago".
Anybody know how to do this? Thanks.
P.S I currently have no code from testing this as I have no idea where to start in terms of achieving this.
Use DateDiff
<cfset days = dateDiff("d", LoginDateVariable, now()) />
It's as simple as that.
P.S I currently have no code from testing this as I have no idea where
to start in terms of achieving this.
This doesn't answer your direct question but to help you know where to get started, I would strongly suggest reviewing the built in ColdFusion functions and tags that are available to you.
Tags
Tags by function
Functions
Functions by category
Also, Google searches usually land you at the docs, just add "coldfusion" to your search string. Searching google for coldfusion date functions yields very helpful answers, the first of which are a list of all ColdFusion date functions.
Dale's answer is spot on. But I would also suggest returning it as a variable with your query. Let the SQL server do the work. It's very efficient for those types of calculations. Not that CF can't do them well, too. But it's probably more appropriate for SQL to do that lifting. Especially if you're already returning the lastLogin date.
It would be similar to the CF solution:
SELECT ...., lastLogin, DATEDIFF(d, lastLogin, GETDATE()) AS LastLoginDays
FROM ....
WHERE ....
That would give you the number of days. You'd have to decide how you wanted to define a month if you wanted to break it out by month/day. That would get a bit more complex. You could write a SQL function that could be run on both dates and give you an accurate count of days/months/years since last login.
One other thing to keep in mind: Where are the dates being generated? When you insert loginDate into the database, are you doing a now() in CF before you insert it or are you doing a getDate() in SQL when you insert it? Again, I would let the database do your date logic, but you'd want to compare the two dates from the same source. For instance, if your loginDate was a database getDate() then you may not want to compare that to a CF now(). One goes by the datetime of the SQL server and the other goes by the datetime of the CF server. They could be different.
I'm try to get birth data for contacts but if user does not choose year or the contact come from Facebook and the year or the data it self is hidden so it give me the "1604" value for the year u can see what i mean in the image.
Congratulations, you've discovered an implementation detail!
First off, Contacts stores dates as points in time, and it is impossible to store a point in time without a year, because every point in time has a year. Thus, a decision had to be made about how Address Book would store an "unknown" year in a date. It was decided that "1604" would be a fine year, for several reasons:
When you're talking about Address Book, it is unlikely that you'll have anyone in your address book who was born in 1604.
1604 was a leap year (by the rules of how leap years are calculated), which means that if the person whose birth year you don't know was born on February 29th, then 1604 could handle that, too.
1604 was before the Julian-Gregorian calendar switch.
Thus, if you're pulling birthdates out of Address Book, you'll need to special-case 1604 as the "birthdate where the year is unknown".
Note: To my knowledge, this is only supported when dealing with the Gregorian calendar. For all other calendars, this behavior is undefined.
You can init the year in viewDidLoad.
Or check if the year was not chosen by the user, present error message.